WebGL viewer: fix help-menu shortcut display - #642
Merged
Conversation
The 'h' help menu had several long-standing display bugs:
- Shortcut keys were rendered with key.toUpperCase(), so a plain
lowercase binding (e.g. key:'h', key:'r', key:'s', key:'l') was shown
as an uppercase letter -- indistinguishable from the genuinely
Shift-modified bindings (key:'R'/'S'/'L' with modKeys:['shiftKey'],
which are different commands). The binding data already carries the
correct case, so render the key verbatim instead of uppercasing it.
- The modifier label was lowercased ("shift"); capitalize it ("Shift").
- #helpmenu was pinned to the left edge (left:0%), so its lower half
slid behind the lower-left legend. Center it horizontally and
vertically (left/top:50% + translate(-50%,-50%)).
- #helpmenu set no font-family, so the panel fell back to the
browser-default serif (Times in Firefox) while the rest of the UI is
sans-serif. Give it an explicit sans-serif.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request centers a UI element and updates the formatting of modifier keys in the MRI viewer. The review feedback suggests using a consistent font family (Helvetica Neue, sans-serif) in the CSS. In the JavaScript code, the reviewer recommends replacing fragile string manipulation for modifier keys with a mapping object, and warns of a potential TypeError if modKeys is undefined during wheel actions.
jackgallant
added a commit
to gallantlab/pycortex-roidraw
that referenced
this pull request
Aug 19, 2026
Direction set by Jack: roidraw conforms to pycortex — pycortex itself is never changed — so that the feature PR proposed in gallantlab/pycortex#642 lands as native-reading pycortex code. - upstream/stage_into_pycortex.py: stages the exact 4-part PR diff into a pycortex checkout, modeled line-for-line on the merged-precedent pattern for optional webgl features (the guided-tour PR #660): the built bundle as resources/js/roidraw.js, a {% if roidraw %} template block (script tag + the same window.ROIDraw.autoAttach() line bake.py injects), a make_static(roidraw=False) kwarg/docstring/template flag, and cortex/tests/test_webgl_roidraw.py (mirrors test_webgl_tour.py). Patches are transactional and fail loudly naming a missing or ambiguous anchor: in the real view.py both the title docstring block and the "leapmotion=True," line occur twice (make_static + the dynamic-viewer path), so the anchors carry disambiguating context. - Bundle global renamed ROIDrawBundle -> roidraw (lowercase, matching pycortex's mriview/svgoverlay module globals); window.ROIDraw stays the documented API. bundle.test.js asserts both handles are the same object. - test/test_upstream.py: patch functions unit-tested against verbatim fixtures of the pycortex anchor regions (incl. the double-occurrence traps), plus htmlembed-compatibility guards — cortex/webgl/htmlembed.py regex-rewrites "new Worker(" and "attr('src'," inside every embedded script, so the bundle must never contain either; its CSS rides inside the JS because _embed_css cannot parse nested at-rule braces. - README "Upstreaming into pycortex" section + TESTING.md coverage notes. Verified against a disposable worktree of pycortex origin/main (5af26a86): staged diff matches the tour PR's shape, rerun is a no-op, patched view.py parses, real-Tornado template render includes the script with roidraw=True and is clean with False, and the renamed-global bundle re-passed the full headless-Firefox viewer smoke. 174 JS + 19 Python tests, lint clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Revert the #helpmenu recentering from dfa64ec. Centering the panel puts it on top of the brain, which is worse than the original left-edge placement -- the overlap with the lower-left legend is the lesser problem. Restores left:0% / translate(0%, -50%). The other help-menu fixes from that commit (verbatim shortcut key case, capitalized modifier labels, explicit sans-serif font-family) are kept. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
mvdoc
added a commit
to mvdoc/pycortex
that referenced
this pull request
Aug 21, 2026
* origin/main: (44 commits) WebGL viewer: make opacity slider and `o` toggle work for Vertex data (gallantlab#685) docs(mapper): add get_mapper docstring (gallantlab#686) ENH add types for dataset classes (BrainData, Dataview, ...) (gallantlab#669) Allow viewer data to be updated in real-time (gallantlab#675) FIX: fix minor bug in handling of vmin and vmax when not specified (replaces old cast code) (gallantlab#681) docs: correct the sulcus install instructions, which destroyed existing sulci (gallantlab#657) WebGL viewer: fix help-menu shortcut display (gallantlab#642) MNT ignore docs build outputs written into the source tree (gallantlab#680) DOC fix build warnings (gallantlab#673) webgl: bind an OS-assigned ephemeral port for the viewer server (gallantlab#676) ENH add types for Database and transforms (gallantlab#667) MNT remove obsolete Python 2 syntax, add some types (gallantlab#666) Bump JamesIves/github-pages-deploy-action from 4.8.0 to 4.9.0 (gallantlab#671) Bump actions/setup-python from 6 to 7 (gallantlab#661) docs: document in-browser sulcus drawing (pycortex-roidraw v0.4.0) (gallantlab#656) ENH Pure-python surf2surf matrix (direct nnfr construction) (gallantlab#651) Bump actions/cache from 5 to 6 (gallantlab#654) webgl: fix overlay/label async texture-bake races (complete) (gallantlab#653) docs: add in-browser ROI drawing (pycortex-roidraw) page (gallantlab#652) FIX: update BuWtRd and BuWtRd_alpha colormaps to have pure white at center, more sensible for biphasic data (gallantlab#649) ... # Conflicts: # cortex/quickflat/composite.py # cortex/utils.py # cortex/webgl/resources/js/shaderlib.js # cortex/webgl/view.py
alexhuth
pushed a commit
that referenced
this pull request
Aug 21, 2026
* WebGL viewer: fix help-menu shortcut display and panel position
The 'h' help menu had several long-standing display bugs:
- Shortcut keys were rendered with key.toUpperCase(), so a plain
lowercase binding (e.g. key:'h', key:'r', key:'s', key:'l') was shown
as an uppercase letter -- indistinguishable from the genuinely
Shift-modified bindings (key:'R'/'S'/'L' with modKeys:['shiftKey'],
which are different commands). The binding data already carries the
correct case, so render the key verbatim instead of uppercasing it.
- The modifier label was lowercased ("shift"); capitalize it ("Shift").
- #helpmenu was pinned to the left edge (left:0%), so its lower half
slid behind the lower-left legend. Center it horizontally and
vertically (left/top:50% + translate(-50%,-50%)).
- #helpmenu set no font-family, so the panel fell back to the
browser-default serif (Times in Firefox) while the rest of the UI is
sans-serif. Give it an explicit sans-serif.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* WebGL viewer: keep the help menu anchored to the left edge
Revert the #helpmenu recentering from dfa64ec. Centering the panel puts
it on top of the brain, which is worse than the original left-edge
placement -- the overlap with the lower-left legend is the lesser
problem. Restores left:0% / translate(0%, -50%).
The other help-menu fixes from that commit (verbatim shortcut key case,
capitalized modifier labels, explicit sans-serif font-family) are kept.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Matteo Visconti di Oleggio Castello <mvdoc@berkeley.edu>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes several long-standing display bugs in the WebGL viewer's
hhelp menu.Bug fixes (ready to merge)
Small, self-contained diff in
mriview.js+mriview.css:key.toUpperCase(). The viewer binds both plain lowercase keys (r,s,l,h, …) and genuinely Shift-modified ones (key:'R'/'S'/'L'withmodKeys:['shiftKey']— these are different commands, e.g. toggle right hemisphere). Uppercasing made the two indistinguishable in the menu (both shown asR/S/L), and the help togglehwas shown asH(implying Shift+H). The binding data already carries the correct case, so we now render the key verbatim.shiftKeynow renders asShiftinstead ofshift.#helpmenuwas pinned to the left edge (left:0%), so its lower half slid behind the lower-left legend. It's now centered (left/top:50%+translate(-50%,-50%)).#helpmenuset nofont-family, so it fell back to the browser-default serif (Times in Firefox) while the rest of the UI is sans-serif. Now explicitly sans-serif.(Note on Firefox scroll-zoom: it's already correct on
main— the active camera controller inmovement.jsuses the standardwheel/deltaY. Only the legacyLandscapeControls.js, used bysimple.html, still reads the WebKit-onlywheelDelta, so it's intentionally left out of this PR.)🤖 Generated with Claude Code