qtconsole icon indicating copy to clipboard operation
qtconsole copied to clipboard

The Select All shortcut is broken on macOS

Open Kentzo opened this issue 7 years ago • 2 comments

Related to #257

On macOS pressing the Cmd-A shortcut will always select the whole document bypassing the step that selects the cell.

The issue only happens when using the shortcut. Using the menu item directly works as expected: first it selects content of the cell, then it selects content of the console.

It likely happens, because QWidgetTextControl (private parent Qt class for QTextEdit and QPlainTextEdit) implements the Select All shortcut (which is resolved into key codes depending on the OS).

The solution I propose is:

  1. Remove conditional mapping in console_widget.py and mainwindow.py
  2. Reject Select All events coming into the control by adding
    if obj == self._control and event == QtGui.QKeySequence.SelectAll:
        return True
    

The event will then be propagated properly into mainwindow and custom select all logic will be triggered.

Kentzo avatar Dec 05 '18 04:12 Kentzo

Sounds good. Please submit a pull request and a test for it. Thanks!

ccordoba12 avatar Dec 05 '18 13:12 ccordoba12

@ccordoba12 I will, but I'd like to understand the need for https://github.com/jupyter/qtconsole/commit/478f2437cd6b48f156031a58969678a716646d40 and https://github.com/jupyter/qtconsole/commit/f2785541618a940ad74363e6b28d0a542e3c1a87a.

Could someone remove that code and test on Windows / Linux?

Kentzo avatar Dec 07 '18 23:12 Kentzo