This class allows us to catch key events on Python controls and pass them through to our event queue (and consequently allowing our viewer to respond appropriately).
PLEASE NOTE: this mixin cannot pass events to our queue unless you tell it about the queue. If you ever derive from this mixin, be sure to call setEventQueue at some point or event passing will not work.
Derived class can catch key events for their own purposes by overriding OnKeyDown() and OnKeyUp(). Be sure call the parent method.
See Bug #222832, #228342 for more info.
Public Member Functions |
|
__init__ () | |
onKeyDown and onKeyUp will always call Skip
for the the key codes in keyCodesToSkip. |
|
setEventQueue () | |
Must call this method so we can queue up the
key up/down events. |
|
eventQueue () | |
setControls () | |
Call this function with a list or tuple of
all the controls that may accept keyboard focus in your window or
dialog. |
|
isModifierKeyEvent () | |
Return True if the specified key event
involves a modifier. |
|
isFunctionKeyEvent () | |
Return True if the key event corresponds to
a function key. |
|
isSingleKeyEvent () | |
Return True if the specified key event
corresponds to a single key that is not a modifier key and does not
have any modifiers down. |
|
OnKeyDown () | |
Convert the Python event to one of our own
and throw it on the queue. |
|
OnKeyUp () | |
Convert the Python event to one of our own
and throw it on the queue. |
|
Public Attributes |
|
tuple | kFunctionKeys |
EventPasser.EventPasser.__init__ | ( | ) |
onKeyDown and onKeyUp will always call Skip for the the key codes in keyCodesToSkip.
EventPasser.EventPasser.setEventQueue | ( | ) |
Must call this method so we can queue up the key up/down events.
EventPasser.EventPasser.eventQueue | ( | ) |
EventPasser.EventPasser.setControls | ( | ) |
Call this function with a list or tuple of all the controls that may accept keyboard focus in your window or dialog.
To each control an event callback is attached to catch both key up and down events.
EventPasser.EventPasser.isModifierKeyEvent | ( | ) |
Return True if the specified key event involves a modifier.
EventPasser.EventPasser.isFunctionKeyEvent | ( | ) |
Return True if the key event corresponds to a function key.
EventPasser.EventPasser.isSingleKeyEvent | ( | ) |
Return True if the specified key event corresponds to a single key that is not a modifier key and does not have any modifiers down.
For example:
Key Modifiers Down Returns --- -------------- ------- m none True a Ctrl False Ctrl none False Shift Alt False
The reason for detecting single key events is because we do not want to pass them to the viewer's event queue. Until now we did pass them and the result was all single key hotkeys would get invoked while a window had focus. This caused all kinds of weird behaviour like going full screen on space, switching between view/author mode on tab, tumbling the scene on right or left arrow.
EventPasser.EventPasser.OnKeyDown | ( | ) |
Convert the Python event to one of our own and throw it on the queue.
If you override this method then be sure to call it from your method.
Returns True if an event was passed to the event queue.
EventPasser.EventPasser.OnKeyUp | ( | ) |
Convert the Python event to one of our own and throw it on the queue.
If you override this method then be sure to call it from your method.
Returns True if an event was passed to the event queue.
set( (
wx.WXK_F1
, wx.WXK_F2
, wx.WXK_F3
, wx.WXK_F4
, wx.WXK_F5
, wx.WXK_F6
, wx.WXK_F7
, wx.WXK_F8
, wx.WXK_F9
, wx.WXK_F10
, wx.WXK_F11
, wx.WXK_F12
, wx.WXK_F13
, wx.WXK_F14
, wx.WXK_F15
, wx.WXK_F16
, wx.WXK_F17
, wx.WXK_F18
, wx.WXK_F19
, wx.WXK_F20
, wx.WXK_F21
, wx.WXK_F22
, wx.WXK_F23
, wx.WXK_F24
) )