Many modern mice and keyboard have more or less useful fancy extra buttons, like forward and backwards buttons used when browsing the Internet. Unfortunately, the hardware manufacturers haven't agreed on a standard for handling these mice, which makes it hard for application programmers to add support for such buttons.

On Windows

Logitech devices

These drivers emit key combinations; alt+numpad right for forward, alt+numpad left for backwards. To handle this, you just need a handler for wx.EVT_CHAR:

   1     def OnChar(self, event):
   2         if event.AltDown() and event.GetKeyCode() == wx.WXK_NUMPAD_RIGHT:
   3             cp = self.GetDocument().GetCommandProcessor().Redo()
   4         if event.AltDown() and event.GetKeyCode() == wx.WXK_NUMPAD_LEFT:
   5             cp = self.GetDocument().GetCommandProcessor()
   6             if cp.CanUndo():
   7                 cp.Undo()

Microsoft devices

Microsoft has documented their behaviour very well. See for example this article from MSDN. They defined a few new windows messages for this. To handle these messages I think you need to hook into the raw windows message flow (see HookingTheWndProc). I'm not an expert on wxPython, so I don't know if there's a better way of doing it. The message you need to detect is the WM_APPCOMMAND, which has the numerical ID 0x0319.

I have no idea how to implement similar behaviour on linux, but feel free to add that. Or if you have a better way of handling the WM_APPCOMMAND.

ForwardBackwardButtons (last edited 2008-03-11 10:50:32 by localhost)

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.