Show More
@@ -197,11 +197,8 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||||
197 | self.paste(QtGui.QClipboard.Selection) |
|
197 | self.paste(QtGui.QClipboard.Selection) | |
198 | return True |
|
198 | return True | |
199 |
|
199 | |||
200 |
# Override short |
|
200 | # Override shortcuts for all filtered widgets. | |
201 | # always unnecessary to override shortcuts, hence the check below (users |
|
|||
202 | # should just use the Control key instead of the Command key). |
|
|||
203 | elif etype == QtCore.QEvent.ShortcutOverride and \ |
|
201 | elif etype == QtCore.QEvent.ShortcutOverride and \ | |
204 | sys.platform != 'darwin' and \ |
|
|||
205 | self._control_key_down(event.modifiers()) and \ |
|
202 | self._control_key_down(event.modifiers()) and \ | |
206 | event.key() in self._shortcuts: |
|
203 | event.key() in self._shortcuts: | |
207 | event.accept() |
|
204 | event.accept() | |
@@ -646,19 +643,23 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||||
646 | self._control.setTextCursor(cursor) |
|
643 | self._control.setTextCursor(cursor) | |
647 | self._text_completing_pos = current_pos |
|
644 | self._text_completing_pos = current_pos | |
648 |
|
645 | |||
649 | def _control_key_down(self, modifiers): |
|
646 | def _control_key_down(self, modifiers, include_command=True): | |
650 | """ Given a KeyboardModifiers flags object, return whether the Control |
|
647 | """ Given a KeyboardModifiers flags object, return whether the Control | |
651 | key is down (on Mac OS, treat the Command key as a synonym for |
|
648 | key is down. | |
652 | Control). |
|
|||
653 | """ |
|
|||
654 | down = bool(modifiers & QtCore.Qt.ControlModifier) |
|
|||
655 |
|
|
649 | ||
656 | # Note: on Mac OS, ControlModifier corresponds to the Command key while |
|
650 | Parameters: | |
657 | # MetaModifier corresponds to the Control key. |
|
651 | ----------- | |
|
652 | include_command : bool, optional (default True) | |||
|
653 | Whether to treat the Command key as a (mutually exclusive) synonym | |||
|
654 | for Control when in Mac OS. | |||
|
655 | """ | |||
|
656 | # Note that on Mac OS, ControlModifier corresponds to the Command key | |||
|
657 | # while MetaModifier corresponds to the Control key. | |||
658 | if sys.platform == 'darwin': |
|
658 | if sys.platform == 'darwin': | |
659 |
down = |
|
659 | down = include_command and (modifiers & QtCore.Qt.ControlModifier) | |
660 |
|
660 | return bool(down) ^ bool(modifiers & QtCore.Qt.MetaModifier) | ||
661 | return down |
|
661 | else: | |
|
662 | return bool(modifiers & QtCore.Qt.ControlModifier) | |||
662 |
|
663 | |||
663 | def _create_control(self): |
|
664 | def _create_control(self): | |
664 | """ Creates and connects the underlying text widget. |
|
665 | """ Creates and connects the underlying text widget. |
@@ -196,7 +196,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
196 | """ Reimplemented to allow execution interruption. |
|
196 | """ Reimplemented to allow execution interruption. | |
197 | """ |
|
197 | """ | |
198 | key = event.key() |
|
198 | key = event.key() | |
199 | if self._control_key_down(event.modifiers()): |
|
199 | if self._control_key_down(event.modifiers(), include_command=False): | |
200 | if key == QtCore.Qt.Key_C and self._executing: |
|
200 | if key == QtCore.Qt.Key_C and self._executing: | |
201 | self.interrupt_kernel() |
|
201 | self.interrupt_kernel() | |
202 | return True |
|
202 | return True |
General Comments 0
You need to be logged in to leave comments.
Login now