Hi,
I am trying to Emulate a key press on an editBox under the KeyDown event.
This code does not work at all:
self.Bind (wx.EVT_KEY_DOWN, self.OnKeyDown)
def OnKeyDown(self, evt):
if evt.GetKeyCode == wx.WXK_END:
evt.m_keyCOde=wx.WXK_DOWN
self.EmulateKeyPress(evt)
What I miss?
Gianluca
Not entirely sure what you're trying to do here, but you have an
uppercase O in evt.m_keyCOde so maybe that's the problem?
Also, if you're trying to emulate a press of the down arrow key to move
the cursor to the next line when a user presses End, please don't do
this. As a user who exclusively uses the keyboard, this would drive me
insane. The End key does what it does for a reason.
sorry I missed by copying the code. The original version is correct.
The use of end is only for test purpose.
I would to change the amount of lines that the pageup and pagedown scrolls when pressed.
In particular way, I should scroll the text until the chr(12) is encountered.
Another problem is that if I use self.ScrollLines it works but the line is not announced by screen readers.
To have the right behaviour I sould emulate a keyUp and sudenly a keyDown to have the line spoken.
I hope this is clearer now.
Gianluca
···
Il 09/09/2013 14.43, James Scholes ha scritto:
Gianluca Casalino wrote:
Hi,
I am trying to Emulate a key press on an editBox under the KeyDown event.
This code does not work at all:
self.Bind (wx.EVT_KEY_DOWN, self.OnKeyDown)
def OnKeyDown(self, evt):
if evt.GetKeyCode == wx.WXK_END:
evt.m_keyCOde=wx.WXK_DOWN
self.EmulateKeyPress(evt)
What I miss?
Gianluca
Not entirely sure what you're trying to do here, but you have an
uppercase O in evt.m_keyCOde so maybe that's the problem?
Also, if you're trying to emulate a press of the down arrow key to move
the cursor to the next line when a user presses End, please don't do
this. As a user who exclusively uses the keyboard, this would drive me
insane. The End key does what it does for a reason.
sorry I missed by copying the code. The original version is correct.
The use of end is only for test purpose.
I would to change the amount of lines that the pageup and pagedown
scrolls when pressed.
In particular way, I should scroll the text until the chr(12) is
encountered.
Another problem is that if I use self.ScrollLines it works but the line
is not announced by screen readers.
To have the right behaviour I sould emulate a keyUp and sudenly a
keyDown to have the line spoken.
I hope this is clearer now.
EmulateKeyPress is not very bullet-proof. It usually does okay with plain text, but definitely not with flow-control keys. To do things like the above I would suggest just doing them programmatically instead of trying to get the widget to do them itself by shoving key events down its throat. Also, don't forget to call evt.Skip() for those key events that you want the textctrl to handle normally.
Hi,
thanks for your kind reply. An idea on how to accomplish it programatically?
Gianluca
···
Il 10/09/2013 2.14, Robin Dunn ha scritto:
Gianluca Casalino wrote:
sorry I missed by copying the code. The original version is correct.
The use of end is only for test purpose.
I would to change the amount of lines that the pageup and pagedown
scrolls when pressed.
In particular way, I should scroll the text until the chr(12) is
encountered.
Another problem is that if I use self.ScrollLines it works but the line
is not announced by screen readers.
To have the right behaviour I sould emulate a keyUp and sudenly a
keyDown to have the line spoken.
I hope this is clearer now.
EmulateKeyPress is not very bullet-proof. It usually does okay with plain text, but definitely not with flow-control keys. To do things like the above I would suggest just doing them programmatically instead of trying to get the widget to do them itself by shoving key events down its throat. Also, don't forget to call evt.Skip() for those key events that you want the textctrl to handle normally.