Enable: adding meta key as a modifier

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Enable: adding meta key as a modifier

Tony S Yu
When using Chaco with the QT backend on OS X, the control key gets mapped to QT's meta key. Would it be possible to add meta to Enable's list of modifier keys?

Below are some patches to add the meta modifier. This seems to work for the Qt backend. Something similar to the diff for qt4_backend/window.py (final diff below) would need to be done for wx_backend/window.py.

Best,
-Tony


P.S. Supposedly, the command key in OS X is mapped to QT's control keys. Unfortunately, this only seems to work immediately after switching windows in Spaces; i.e. it's really buggy. Has anyone else come across this problem?


P.P.S. To answer the question "# what is this??" (see first diff below) Event.event is the original event object from the GUI backend (e.g. it's a Qt event object when using Qt as the backend).


Index: enthought/enable/events.py
===================================================================
--- enthought/enable/events.py (revision 25642)
+++ enthought/enable/events.py (working copy)
@@ -146,6 +146,7 @@
     # high-bit and control characters.  (See subpackage wx.window.key_map)
     character    = ReadOnly
     alt_down     = ReadOnly
+    meta_down    = ReadOnly
     control_down = ReadOnly
     shift_down   = ReadOnly
     event        = ReadOnly    # what is this??

Index: enthought/enable/base_tool.py
===================================================================
--- enthought/enable/base_tool.py (revision 25642)
+++ enthought/enable/base_tool.py (working copy)
@@ -35,6 +35,7 @@
         self.key = key
         mods = [m.lower() for m in modifiers]
         self.alt = "alt" in mods
+        self.meta = "meta" in mods
         self.shift = "shift" in mods
         self.control = "control" in mods
         return
@@ -46,6 +47,7 @@
         """
         if (self.key == getattr(event, 'character',None)) and \
            (self.alt == event.alt_down) and \
+           (self.meta == event.meta_down) and \
            (self.control == event.control_down) and \
            (self.shift == event.shift_down):
             return True

Index: enthought/enable/qt4_backend/window.py
===================================================================
--- enthought/enable/qt4_backend/window.py (revision 25642)
+++ enthought/enable/qt4_backend/window.py (working copy)
@@ -104,6 +104,7 @@
         enable_event = KeyEvent(character=key, x=x,
                 y=self._enable_window._flip_y(y),
                 alt_down=bool(modifiers & QtCore.Qt.AltModifier),
+                meta_down=bool(modifiers & QtCore.Qt.MetaModifier),
                 shift_down=bool(modifiers & QtCore.Qt.ShiftModifier),
                 control_down=bool(modifiers & QtCore.Qt.ControlModifier),
                 event=event,


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev