The objective is to press the button to replace Confirm action and the Cancel action of the shortcuts with an actual button. For example for a crop operation to Confirm it or Cancel it.
I managed to find how to press Enter but I fear it only does that. So when I press the button I trigger:
def Question_Confirm( self ):
ki = Krita.instance()
ad = ki.activeDocument()
widget = ki.activeWindow().activeView().canvas()
event = QKeyEvent( QEvent.KeyPress, Qt.Key_Return, Qt.NoModifier )
QApplication.sendEvent( widget, event )
self.Wait( ad )
However to press escape things do not really work and somehow it is treated as a Confirm action.
def Question_Cancel( self ):
ki = Krita.instance()
ad = ki.activeDocument()
widget = ki.activeWindow().activeView().canvas()
event = QKeyEvent( QEvent.KeyPress, Qt.Key_Escape, Qt.NoModifier )
QApplication.postEvent( widget, event )
self.Wait( ad )
What am I doing wrong ? or How do you trigger a key shortcut through code ? to activate a action that does not exist ?