##// END OF EJS Templates
Fixed wonky ConsoleWidget keyboard shortcuts on Mac OS.
epatters -
Show More
@@ -163,9 +163,13 b' class ConsoleWidget(QtGui.QPlainTextEdit):'
163 def event(self, event):
163 def event(self, event):
164 """ Reimplemented to override shortcuts, if necessary.
164 """ Reimplemented to override shortcuts, if necessary.
165 """
165 """
166 # On Mac OS, it is always unnecessary to override shortcuts, hence the
167 # check below. Users should just use the Control key instead of the
168 # Command key.
166 if self.override_shortcuts and \
169 if self.override_shortcuts and \
170 sys.platform != 'darwin' and \
167 event.type() == QtCore.QEvent.ShortcutOverride and \
171 event.type() == QtCore.QEvent.ShortcutOverride and \
168 event.modifiers() & QtCore.Qt.ControlModifier and \
172 self._control_down(event.modifiers()) and \
169 event.key() in self._ctrl_down_remap:
173 event.key() in self._ctrl_down_remap:
170 event.accept()
174 event.accept()
171 return True
175 return True
@@ -192,7 +196,7 b' class ConsoleWidget(QtGui.QPlainTextEdit):'
192 cursor = self.textCursor()
196 cursor = self.textCursor()
193 position = cursor.position()
197 position = cursor.position()
194 key = event.key()
198 key = event.key()
195 ctrl_down = event.modifiers() & QtCore.Qt.ControlModifier
199 ctrl_down = self._control_down(event.modifiers())
196 alt_down = event.modifiers() & QtCore.Qt.AltModifier
200 alt_down = event.modifiers() & QtCore.Qt.AltModifier
197 shift_down = event.modifiers() & QtCore.Qt.ShiftModifier
201 shift_down = event.modifiers() & QtCore.Qt.ShiftModifier
198
202
@@ -507,6 +511,20 b' class ConsoleWidget(QtGui.QPlainTextEdit):'
507 # 'ConsoleWidget' protected interface
511 # 'ConsoleWidget' protected interface
508 #--------------------------------------------------------------------------
512 #--------------------------------------------------------------------------
509
513
514 def _control_down(self, modifiers):
515 """ Given a KeyboardModifiers flags object, return whether the Control
516 key is down (on Mac OS, treat the Command key as a synonym for
517 Control).
518 """
519 down = bool(modifiers & QtCore.Qt.ControlModifier)
520
521 # Note: on Mac OS, ControlModifier corresponds to the Command key while
522 # MetaModifier corresponds to the Control key.
523 if sys.platform == 'darwin':
524 down = down ^ bool(modifiers & QtCore.Qt.MetaModifier)
525
526 return down
527
510 def _complete_with_items(self, cursor, items):
528 def _complete_with_items(self, cursor, items):
511 """ Performs completion with 'items' at the specified cursor location.
529 """ Performs completion with 'items' at the specified cursor location.
512 """
530 """
General Comments 0
You need to be logged in to leave comments. Login now