Skip to content

Fix HelpBrowser key shortcuts#7542

Draft
prko wants to merge 42 commits into
supercollider:developfrom
prko:topic/helpbrowser_key_shortcuts
Draft

Fix HelpBrowser key shortcuts#7542
prko wants to merge 42 commits into
supercollider:developfrom
prko:topic/helpbrowser_key_shortcuts

Conversation

@prko

@prko prko commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

For the current state of this PR, see #7542 (comment).


closes: #7539

Modifying HelpBrowser.cpp and overriding_action.hpp in this PR was assisted by some AIs, and I reviewed it based on the experience from #7534.

Purpose and Motivation

This PR fixes most of the inconsistent behaviours described in #7539.

  • Cmd/Ctrl + R

    • Linux & macOS: Refreshes the HelpBrowser (both inside and outside the code editor)
    • Windows: No action
  • Cmd/Ctrl + =, Cmd/Ctrl + 0, Cmd/Ctrl + -

    • All platforms: Adjust font size (both inside and outside the code editor)

Additionally, navigating to the previous and next pages now works consistently across all platforms, both inside and outside the code editor.

Types of changes

  • Bug fix

To‑do list

  • Code is tested
  • All tests are passing
  • This PR is ready for review

@prko prko marked this pull request as draft June 4, 2026 15:43
@prko prko force-pushed the topic/helpbrowser_key_shortcuts branch from e5e2041 to 9c16f4d Compare June 4, 2026 15:45
Update help_browser.cpp

Update help_browser.cpp

Update help_browser.cpp

update HelpBrowser.sc and HelpBrowser.schelp

Update help_browser.cpp

Update help_browser.cpp

Update help_browser.cpp

Update help_browser.cpp

Update help_browser.cpp

Update help_browser.cpp

Update help_browser.cpp

Update help_browser.cpp

Update help_browser.cpp

Update help_browser.cpp

Update help_browser.cpp

Update help_browser.cpp

Update help_browser.cpp

Update help_browser.cpp

Update help_browser.cpp

Update help_browser.cpp
@prko prko force-pushed the topic/helpbrowser_key_shortcuts branch from f0bf977 to 14394a3 Compare June 4, 2026 15:49
@prko

prko commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

With Update overriding_action.hpp, “Ctrl + =” and “Ctrl + +” enlarge the font size on both Ubuntu and Windows.
On macOS, “Cmd + =” enlarges the HelpBrowser font size, while “Cmd + +” enlarges the SC‑IDE code editor font size. I think this behavior is acceptable.

I will try blocking “Cmd + +” in the HelpBrowser so that it no longer enlarges the SC‑IDE code editor font size.

@prko

prko commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

I am giving up on resolving the issue where Cmd + + in the HelpBrowser enlarges the font size in the SC‑IDE code editor.
If other developers also cannot find any clues after b4ac8c7, b4ac8c7 should be the final one. Please let me know.

For help_browser.cpp and overriding_action.hpp, I followed the AI’s guidance and applied the necessary changes, removing anything that seemed unnecessary. At this point, reviewers should check whether the code is clean and ready to be considered final.

@prko prko marked this pull request as ready for review June 5, 2026 01:25

@dyfer dyfer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know about the Qt changes, just caught a couple of cosmetic ones.

Comment thread HelpSource/Classes/HelpBrowser.schelp Outdated
Comment thread HelpSource/Classes/HelpBrowser.schelp Outdated

@capital-G capital-G left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjust font size (both inside and outside the code editor)

IMO zooming on the help browser should be independent of the editor, since the help browser also has text which the text editor can not display (i.e. non-monospaced text). I may want to therefore change the layout w/o changing my own written code.

Comment thread editors/sc-ide/widgets/help_browser.cpp Outdated
Comment thread editors/sc-ide/core/util/overriding_action.hpp Outdated
Comment thread editors/sc-ide/widgets/help_browser.cpp Outdated
Comment thread editors/sc-ide/widgets/help_browser.cpp Outdated
Comment thread editors/sc-ide/widgets/help_browser.cpp Outdated

mActions[ZoomIn]->setShortcut(settings->shortcut("editor-enlarge-font"));
QList<QKeySequence> zoomInShortcuts;
zoomInShortcuts.append(settings->shortcut("editor-enlarge-font"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO pressing Cmd + on the help browser shouldn't affect the editor font? I would it expect to zoom in on the layout of the help browser?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d also like to hear your thoughts on this. To clarify the current situation: the behaviour is already correct on Windows and Linux. This inconsistent behaviour only occurs on macOS, and it is not introduced by this PR.

To avoid confusion, let's define the terms:

  • SC‑IDE Code Editor → the main code editor in SC‑IDE
  • HelpBrowser codeMirrorContainer → the <div class="codeMirrorContainer"> inside the HelpBrowser HTML

Here is how macOS behaves across different versions:


SC 3.14 to current (without this PR)

When clicking outside codeMirrorContainer:

  • Cmd + → increases font size in the SC‑IDE Code Editor - Cmd = → increases font size in the HelpBrowser

When clicking inside codeMirrorContainer:

  • Cmd + → increases font size in the SC‑IDE Code Editor - Cmd =does nothing

SC 3.13 (and earlier) / With this PR applied

When clicking outside codeMirrorContainer:

  • Cmd + → increases font size in the SC‑IDE Code Editor
  • Cmd = → increases font size in the HelpBrowser

When clicking inside codeMirrorContainer:

  • Cmd + → increases font size in the SC‑IDE Code Editor - Cmd = → increases font size in the HelpBrowser

Summary

The issue you pointed out (Cmd + enlarges SC-IDE code editor font) is an older, pre-existing macOS‑specific problem. This PR simply fixes the regression introduced in SC 3.14 and restores the expected behaviour from SC 3.13 (where Cmd = at least works consistently inside the HelpBrowser codeMirrorContainer).

I did initially spend several hours investigating how to prevent Cmd + in the HelpBrowser from expanding the code editor text—not only in this PR, but also during my work on #7534 and #7521. However, after exploring various approaches, I realised that a proper fix requires a much deeper architectural change. Therefore, I have left it out of scope for this PR so we can focus on resolving the 3.14 regression first.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This summary looks a bit too much ai assisted to me, not a fan of that^^

This PR simply fixes the regression

I'd disagree w/ that - I wouldn't want to have the zoom in shortcut performed on the browser to affect the code editor - I'd argue that the previous behavior is wrong as well, and instead of removing this wiring, you are introducing it here explicitly.

@prko prko Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope this doesn’t come across the wrong way. I just want to share my thoughts openly so we can clear up any misunderstandings and move forward effectively.



I'd disagree w/ that - I wouldn't want to have the zoom in shortcut performed on the browser to affect the code editor - I'd argue that the previous behavior is wrong as well, and instead of removing this wiring, you are introducing it here explicitly.

I think there might be a slight misunderstanding regarding my intention and what this PR actually does.

Let me try to clarify.


I'd argue that the previous behavior is wrong I'd argue that the previous behavior is wrong as well, and instead of removing this wiring, you are introducing it here explicitly.

If you mean I have not yet succeeded in removing the connection between the browser zoom and the editor zoom, then you are entirely right. That is exactly the limitation I was trying to explain.

However, if the meaning is one or all of the following, then that’s a misunderstanding:

  • I think the previous behaviour (pressing "cmd" + "shift" + "=" in HelpBrowser enlarges the font size in SC-IDE Code Editor) is correct.
  • The issue that pressing "cmd" + "shift" + "=" in HelpBrowser enlarges the font size in SC-IDE Code Editor was resolved in 3.14 or in 3.15 before Fix keyboard shortcuts and font reset behavior in HelpBrowser #7534. I am reintroducing the wrong behaviour in this PR.

To be absolutely clear:

  • I agree with you 100% that pressing "cmd" + "shift" + "=" in the HelpBrowser should not affect the SC-IDE Code Editor. It is wrong behaviour.
  • I did not introduce this wiring. This problem has existed long before this PR (in 3.13, 3.14, and likely earlier).
  • I spent hours trying to completely remove this coupling, but as I mentioned, it seems to require a much deeper architectural change that is currently beyond my skill level. That is why I suggested treating it as a separate, out-of-scope issue rather than letting it block the other fixes here.

This summary looks a bit too much ai assisted to me, not a fan of that^^

I did use AI to help soften my phrasing and clean up my English (e.g., it suggested the phrase "a proper fix requires a much deeper architectural change" and it removed a sentence including "regression" which I then rewrote). However, it is strongly based on my own writing.

prko added 13 commits June 6, 2026 07:33
… purpose

The previous implementation used a function-local static variable within HelpBrowser::onPageLoad() to store the Ctrl+R blocker action on Windows.
While functional, this approach obscured the variable's scope and lifetime.

This patch moves the variable into the HelpBrowser class as a private static member, making its role explicit.
Additionally, a brief comment has been added to explain why this blocking action is necessary (to prevent the Ctrl+R shortcut from propagating to the parent SC-IDE editor).

Ref: supercollider#7542 (comment)
@prko

prko commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

I’ve spent an unexpectedly long time (including today, yesterday, and several earlier attempts) looking deeply into the keyboard‑shortcut issue in the HelpBrowser. Unfortunately, handling "Cmd" + "Shift" + "=" on the English keyboard layout has turned out to be more complicated than I anticipated, and I haven’t yet been able to find a reliable solution.

Since the "Cmd" + "Shift" + "=" issue on the English layout is an older, pre‑existing bug rather than something introduced by this PR, I’d like to suggest leaving it outside the scope of this pull request. I think it would be more practical to address it in a separate issue or PR, so that it doesn’t hold up the current platform‑inconsistency fixes.

@capital-G capital-G left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must admit that the code didn't get better since the last review - mainly b/c the code is now much more platform dependent, which is always good to be avoided if possible.

Some comments haven't been addressed, such as the meta key. But while performing a small google search I came across that one https://doc.qt.io/archives/qt-5.15/qkeysequence.html#standard-shortcuts - maybe this could be relevant?

Alternatively - why don't we use the shortcut as defined in the editor? This seems cleanest to me overall

Image

I think a good implementation could be to block these shortcuts from bubbling up (see review comment about eventfilter) and wire them up to the respective action on the helpbrowser widget. No platform dependent code necessary anymore, which is the most preferred solution, and the user can re-assign this and it becomes consistent across help browser and code editor.
This is probably not more than 20 loc?

Comment thread editors/sc-ide/widgets/help_browser.hpp Outdated
Comment on lines +157 to +159
// Blocks the default `Ctrl + R` behavior on Windows, which would otherwise
// trigger an unwanted refresh action in the embedded browser widget.
static QAction* winCtrlRBlocker;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to stop key events from bubbling up, you should use this pattern

bool GenericLookupDialog::eventFilter(QObject* object, QEvent* event) {
if (object == mResult && event->type() == QEvent::KeyPress) {
QKeyEvent* ke = static_cast<QKeyEvent*>(event);
switch (ke->key()) {
case Qt::Key_Enter:
case Qt::Key_Return:
onAccepted(mResult->currentIndex());
return true;
default:;
}
}
return QDialog::eventFilter(object, event);
}

You can read the docs about this at https://doc.qt.io/qt-6/eventsandfilters.html#event-filters

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not configure it. I left this.

Comment thread editors/sc-ide/widgets/help_browser.cpp Outdated
Comment thread editors/sc-ide/widgets/help_browser.cpp Outdated
Comment thread editors/sc-ide/widgets/help_browser.cpp Outdated
Comment thread editors/sc-ide/widgets/help_browser.cpp Outdated
Comment thread editors/sc-ide/widgets/help_browser.cpp Outdated

mActions[ZoomIn]->setShortcut(settings->shortcut("editor-enlarge-font"));
QList<QKeySequence> zoomInShortcuts;
zoomInShortcuts.append(settings->shortcut("editor-enlarge-font"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This summary looks a bit too much ai assisted to me, not a fan of that^^

This PR simply fixes the regression

I'd disagree w/ that - I wouldn't want to have the zoom in shortcut performed on the browser to affect the code editor - I'd argue that the previous behavior is wrong as well, and instead of removing this wiring, you are introducing it here explicitly.

@prko

prko commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

Regarding regressions, here is why I consider some behaviours in 3.14/3.15-dev to be a regression compared to 3.13 when interacting inside the <div class="codeMirrorContainer"> region in HelpBroweser:

  1. Pressing "cmd" + "0"
  1. Pressing "cmd" + "=", "cmd" + "-" and "cmd" + "0" in <div class="codeMirrorContainer"> region in HelpBroweser
  • In SC3.13:
    Changes the font size in HelpBowser.
  • In SC3.14 and in SC3.15.0-dev (before this PR, since this PR fixes it):
    No action. It works only outside <div class="codeMirrorContainer"> in HelpBroweser works.
  1. Code Parsing of SC Code Evaluation in <div class="codeMirrorContainer"> in HelpBroweser
  1. HelpBrowser Stability after SC Code Evaluation in <div class="codeMirrorContainer"> region in HelpBrowser
  • In SC3.13:
    No issues.
  • In SC3.14 and SC3.15.0-dev
    The HelpBrowser sometimes goes completely white when evaluating a code block.

My goal with this PR is simply to restore the working 3.13 behaviors and fix the critical regressions so that the HelpBrowser is at least usable while we figure out a better, cleaner way to implement the event filters you suggested.

Update help_browser.cpp
@prko prko force-pushed the topic/helpbrowser_key_shortcuts branch from 1c2b399 to 7423e60 Compare June 6, 2026 13:07
@prko prko marked this pull request as draft June 6, 2026 14:34
@prko

prko commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

Current state of this PR:

  • Fixed

    • Cmd/Ctrl + = / - / 0 in HelpBrowser (both inside and outside the CodeMirrorContainer)
      • All platforms: Adjusts the font size correctly.
    • Navigation to previous/next pages now works consistently across all platforms (both inside and outside the CodeMirrorContainer in HelpBrowser).
  • Partially Fixed
    (Issues present since at least SC 3.13 or earlier)

    • Cmd/Ctrl + R in HelpBrowser (both inside and outside the CodeMirrorContainer)
      • FIXED (Linux & macOS): Refreshes the HelpBrowser.
      • NOT FIXED (Windows): Still triggers the Find & Replace pane in the SC-IDE code editor.
    • Cmd/Ctrl + Shift + = in HelpBrowser
      • macOS: Increases the font size of the SC-IDE code editor (both inside and outside the CodeMirrorContainer).
      • Linux & Windows: No functionality.
        (Note: In SC 3.15.0-dev, Ctrl + + was fixed to enlarge the HelpBrowser text, but this PR removes that behavior.)

The non-fixed issues are outside the scope of this PR due to my current implementation limitations:

  • On macOS, Cmd/Ctrl + Shift + = increases the font size of the SC-IDE code editor.
  • On Windows, Cmd/Ctrl + R in HelpBrowser still triggers the Find & Replace pane in the SC-IDE code editor.

If these two issues need to be resolved within this PR, I will need assistance from the coauthors.

@prko prko marked this pull request as ready for review June 6, 2026 18:18
@prko

prko commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

I think it is better to convert this PR to a draft. If someone later finds that this PR can be revived, I would be glad for them to continue. It is also completely fine with me if someone opens a new PR to address the issues discussed here and in #7539.

What I have learned from this PR is that using AI in unfamiliar fields can be convenient, but also quite risky.

My mistakes in this PR:

  1. I tried to avoid learning C++ and Qt as much as I could.
  2. I relied on AI to solve issues I didn’t fully understand.
  3. AI can solve some problems quickly, but it can also ruin work if the user’s attention slips. In unfamiliar disciplines, maintaining steady attention is difficult. Even in familiar disciplines, repetitive work (reading, comparing and judging on revised text and code) can easily cause attention to drift.
  4. I focused too much on executing AI‑generated suggestions instead of thinking through the logic myself. This ended up wasting both my time and the reviewer’s time. I apologise to @capital-G for the time and effort he invested.
  5. In my experiences in general, the idea that AI can reliably solve complex problems is almost a fantasy. It feels similar to buying lottery tickets with a vague expectation of a big win.
  6. To contribute responsibly to SuperCollider development, one needs at least to learn the basics of C++. Since I’m not ready to commit to that, I should avoid opening PRs like this. What I can do is contribute to documentation improvements and the SC class file.

@prko prko marked this pull request as draft June 7, 2026 00:42
Comment on lines +212 to +213
mActions[ZoomIn]->setShortcuts(zoomInShortcuts);
mActions[ZoomOut]->setShortcut(settings->shortcut("editor-shrink-font"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried "plain" QKeySequence::ZoomIn and QKeySequence::ZoomOut.
At least it seems off/inconsistent to use the user-provided shortcut for zoom out and some hardcoded values for zooming in ;)

I suggested to use the shortcuts from the editor, but since we are also not using them for refresh etc, it is maybe not bad to use the Qt provided ones?

If you are still interested in the PR, you could give that a try and see how it works out :)

@capital-G

Copy link
Copy Markdown
Contributor

I think it is better to convert this PR to a draft. If someone later finds that this PR can be revived, I would be glad for them to continue. It is also completely fine with me if someone opens a new PR to address the issues discussed here and in #7539.

What I have learned from this PR is that using AI in unfamiliar fields can be convenient, but also quite risky.

from my experience: best results w/ AI are achieved when guiding it rather tight - at least if you care about understanding/maintainability of the code, which we care for here ;)
You could use AI as a "teacher" - e.g. "I'd like to implement feature X - can you guide and explain to me each necessary step".

  1. AI can solve some problems quickly, but it can also ruin work if the user’s attention slips. In unfamiliar disciplines, maintaining steady attention is difficult. Even in familiar disciplines, repetitive work (reading, comparing and judging on revised text and code) can easily cause attention to drift.

Reviewing is also a task ;) Certainly not as fun as coding (IMO), but really necessary and w/ AI this becomes even more important.

  1. I focused too much on executing AI‑generated suggestions instead of thinking through the logic myself. This ended up wasting both my time and the reviewer’s time. I apologise to @capital-G for the time and effort he invested.

No need to apologize here at all! If you learned something along the way, thats fine. I certainly learned something as well :)

  1. To contribute responsibly to SuperCollider development, one needs at least to learn the basics of C++. Since I’m not ready to commit to that, I should avoid opening PRs like this. What I can do is contribute to documentation improvements and the SC class file.

I don't think you do - C++ has some idiosyncrasies, but you can learn those as you go - changes such are these are actually quite manageable IMO - you certainly need to learn something new, but thats the fun part ;)
I can really recommend https://www.learncpp.com/ as a resource, that's how I mostly learned C++.

The code looks much better r/n, and I think some open questions aren't too hard ;)

Regarding the open problems, I took a closer look at this:

HelpBrowser derives from WebView, which also defines some shortcuts

page->action(QWebEnginePage::Copy)->setShortcut(QKeySequence::Copy);
page->action(QWebEnginePage::Paste)->setShortcut(QKeySequence::Paste);
page->action(QWebEnginePage::Reload)->setShortcut(QKeySequence::Refresh);
page->action(QWebEnginePage::Back)->setShortcut(QKeySequence::Back);
page->action(QWebEnginePage::Forward)->setShortcut(QKeySequence::Forward);

See https://doc.qt.io/qt-6/qkeysequence.html#standard-shortcuts for how these translate to.
But you'll notice, that ctrl+r isn't listed as refresh for windows - so we would have to add this manually.

macOS: Increases the font size of the SC-IDE code editor (both inside and outside the CodeMirrorContainer)

So when I now press cmd = within the help editor, the scd document also changes font size? IMO this is not desirable as stated above, also how this can be avoided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix inconsistent HelpBrowser keyboard shortcuts across platforms

3 participants