Add keyboard support
parent
8f4cb3a110
commit
ec0289f55b
|
@ -110,6 +110,7 @@ class GameBoard(BoxBoard):
|
|||
|
||||
self.gamegrid.buttonClicked.connect(self.show_number_ring)
|
||||
self.numring.connect_button_signals(self.select_ring_number)
|
||||
self.numring.keyPressed.connect(self.select_ring_number)
|
||||
|
||||
self.gamegrid.setFocus(Qt.MouseFocusReason)
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ class AnimBox(QGraphicsObject):
|
|||
super().hoverLeaveEvent(event)
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
self.length = 0
|
||||
self.toggle_anim(False)
|
||||
self.buttonClicked.emit(self.text)
|
||||
|
||||
|
||||
|
|
|
@ -226,6 +226,7 @@ class NumberRing(BaseSudokuItem):
|
|||
# TODO: Add functions to animated the ring appearing
|
||||
# TODO: Adjust the positioning of each element
|
||||
# TODO: Make it transparent when mouse is out of range
|
||||
keyPressed = pyqtSignal(str)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
|
@ -314,6 +315,15 @@ class NumberRing(BaseSudokuItem):
|
|||
|
||||
self.update()
|
||||
|
||||
def keyPressEvent(self, event):
|
||||
txt = event.text()
|
||||
if not txt == '' and txt in 'x123456789':
|
||||
if txt == 'x':
|
||||
txt = 'X'
|
||||
print('keypress:', txt)
|
||||
self.keyPressed.emit(txt)
|
||||
self.clearFocus()
|
||||
|
||||
|
||||
class PlayMenu(BaseSudokuItem):
|
||||
buttonClicked = pyqtSignal(str)
|
||||
|
|
Loading…
Reference in New Issue