Jean-Michel Fauth wrote:
Is this an AltGr key problem?
David Hughes wrote:
Have you tried using wxKeyEvent.AltDown()?
Also have a look at wxKeyEvents.py in the demo particularly the bit about
'modifiers'.
Thank you for the replies. It is not an AltGr problem, but I found your
article yesterday. I failed to mention what both of you cited: event.AltDown
is used to identify the modifying in my code. I actually learned of it from
wxKeyEvents.py when I started on the 'speed key' application enhancement.
I also Skip() key ups and downs so the evt_char will fire.
Here's an abridged version of the event handler that works well in Linux but
NOT in WinNT:
# self.txt_msg is the wxTextCtrl
EVT_CHAR(self.txt_msg, self.KeyCapture)
.
.
# ---------------------------------------------------------------
# Key Capture
# ----------------------------------------------------------------
def KeyCapture(self, event):
keycode = event.GetKeyCode()
keyreal = chr(keycode)
last_position = self.txt_msg.GetLastPosition()
curr_position = self.txt_msg.GetInsertionPoint()
curr_value = self.txt_msg.GetValue()
#print 'positions: %s, %s'%(last_position, curr_position)
# handle operations like <ENTER>,<DELETE>,<BACKSPACE>, etc
# one shown, the rest snipped
if (13 == keycode):
self.OnEnterHit(None)
return
.
.
modifiers = ""
for mod, ch in [(event.ControlDown(), 'CTRL'),
(event.AltDown(), 'ALT')]:
if mod:
modifiers += ch
else:
modifiers += ''
# keymod is how the speed key is stored in dict
if ('CTRL' == modifiers):
keymod = modifiers + str(keycode)
else:
keymod = modifiers + keyreal
# SPEED_KEYS is a dict
if (SPEED_KEYS.has_key(keymod)):
translate = ''.join(SPEED_KEYS.get(keymod))
self.txt_msg.SetInsertionPoint(curr_position)
self.txt_msg.WriteText(translate)
else:
self.txt_msg.SetInsertionPoint(curr_position)
self.txt_msg.WriteText(keyreal)
#print 'key: %s keyreal: %s trans: %s'%(keycode, keyreal, translate)