Skip to content

web: pass Ctrl-= through to browser for font size increase#1713

Merged
phkahler merged 2 commits intomasterfrom
copilot/fix-ctrl-plus-zoom
Apr 8, 2026
Merged

web: pass Ctrl-= through to browser for font size increase#1713
phkahler merged 2 commits intomasterfrom
copilot/fix-ctrl-plus-zoom

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 3, 2026

Ctrl-= (the no-Shift convention for Ctrl-plus) was intercepted by SolveSpace's canvas zoom-in handler, blocking the browser from using it to increase font size. Ctrl-minus already passed through unblocked because the ZOOM_OUT accelerator is bound to bare - (no Ctrl), so the match failed and EM_FALSE was returned — but Ctrl-= had a special-case handler in GraphicsWindow::KeyboardEvent that matched regardless of Ctrl state.

Change

Added an early-exit in KeyboardCallback (guihtml.cpp) before any event processing:

// Pass Ctrl-= through to the browser (for font size increase), symmetric with
// Ctrl-minus which is already passed through since it doesn't match any shortcut.
if(emEvent->ctrlKey && strcmp(emEvent->key, "=") == 0) return EM_FALSE;

= without Ctrl continues to trigger canvas zoom-in as before.

Copilot AI linked an issue Apr 3, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix Ctrl-plus functionality for text zooming web: pass Ctrl-= through to browser for font size increase Apr 3, 2026
Copilot AI requested a review from phkahler April 3, 2026 17:44
@phkahler
Copy link
Copy Markdown
Member

phkahler commented Apr 3, 2026

@copilot Why do you think CTRL - works but CRTL = need this change?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 3, 2026

@copilot Why do you think CTRL - works but CRTL = need this change?

The difference is in how each key is handled inside GraphicsWindow::KeyboardEvent:

Ctrl-minus: The ZOOM_OUT accelerator is bound to bare '-' (no Ctrl). When Ctrl-minus arrives, event.controlDown = true, so it doesn't match the accelerator (which expects controlDown = false). No handler claims it → KeyboardEvent returns falseKeyboardCallback returns EM_FALSE → browser sees it and decreases font size. ✓

Ctrl-=: There's a special-case handler at graphicswin.cpp:249 that matches event.chr == '=' without checking controlDown:

} else if(event.chr == '=') {
    // Treat = as +.
    MenuView(Command::ZOOM_IN);
    return true;
}

This fires for both bare = and Ctrl-=, returning true both times. So KeyboardCallback returns EM_TRUE → the browser never sees Ctrl-= → font size increase is blocked. ✗

The fix in guihtml.cpp short-circuits before the event even reaches GraphicsWindow::KeyboardEvent when Ctrl-= is pressed, letting the browser handle it.

Copy link
Copy Markdown
Member

@phkahler phkahler left a comment

Choose a reason for hiding this comment

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

This should work. Another option would be to add a condition to the code that converts "=" to a zoom in menu action (normally "+") to check that the CTRL key is not pressed. This would prevent consumption of the keypress event when CTRL is pressed and return false to the caller, letting the browser handle it.

@phkahler phkahler marked this pull request as ready for review April 8, 2026 16:40
@phkahler phkahler merged commit 08fdb35 into master Apr 8, 2026
9 checks passed
@ruevs
Copy link
Copy Markdown
Member

ruevs commented Apr 8, 2026

Probably the other option would have been cleaner, but this is minimal and non-intrusive.

@phkahler
Copy link
Copy Markdown
Member

phkahler commented Apr 8, 2026

Its been 3 hours since I pushed and this doesn't seem to do anything. ;-(

@ruevs
Copy link
Copy Markdown
Member

ruevs commented Apr 9, 2026

@phkahler yes, it has not updated (the easiest way to check is Help | Go to GitHub commit). It goes to 289651e, while the CTRL+ change is 08fdb35.

I do not know why. Perhaps a rate limiting logic @jwesthues put in?

The CI ran normally and the site responded "good" https://github.com/solvespace/solvespace/actions/runs/24147131706/job/70465587468#step:6:77

The time stamp is "Wed Apr 8 13:00:03 EDT 2026"

The problem is I'm not on a PC and I do not know how to check exact commit time stamps on GitHub.

@jwesthues
Copy link
Copy Markdown
Member

Weird, and not any deliberate rate limiting and not the Cloudflare cache. The CI says it succeeded at 09:55 PDT = 12:55 EDT, /pull-webver.pl got hit at 12:55:41 EDT, and the download happened at 13:00:03 EDT per above; so those all seem correct. Is it possible that the download doesn't work immediately after the CI completes and I need to deliberately wait? I see some unofficial reports of delays in GitHub's CDN.

I re-triggered the download and it worked this time. I've added more logging so that I can debug this better if/when it recurs, but haven't added the delay yet.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blocks Ctrl-plus but not Ctrl-minus

4 participants