MSW ALT key event

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)

Michael Welsh wrote:

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:

How about establishing a base-line first. Does the demo wxKeyEvents.py run
correctly for you i.e. displaying the right modifiers when you press
Ctrl/<char> and Alt/<char> etc? It works fine for me here using Win 2000,
Python 2.3 and wxPython 2.4.1.2. If the demo doesn't run for you (which NT
and Service packs?) I've got an NT4 setup here I could try. If the demo is
OK then it points to a problem with the code you are developing.

David