Skip to content

WebGL viewer: fix help-menu shortcut display - #642

Merged
mvdoc merged 2 commits into
mainfrom
claude/webgl-help-menu-fixes
Aug 20, 2026
Merged

WebGL viewer: fix help-menu shortcut display#642
mvdoc merged 2 commits into
mainfrom
claude/webgl-help-menu-fixes

Conversation

@jackgallant

@jackgallant jackgallant commented May 26, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR fixes several long-standing display bugs in the WebGL viewer's h help menu.

Bug fixes (ready to merge)

Small, self-contained diff in mriview.js + mriview.css:

  1. Shortcut key casing. The help generator rendered every key with key.toUpperCase(). The viewer binds both plain lowercase keys (r, s, l, h, …) and genuinely Shift-modified ones (key:'R'/'S'/'L' with modKeys:['shiftKey'] — these are different commands, e.g. toggle right hemisphere). Uppercasing made the two indistinguishable in the menu (both shown as R/S/L), and the help toggle h was shown as H (implying Shift+H). The binding data already carries the correct case, so we now render the key verbatim.
  2. Modifier-label casing. shiftKey now renders as Shift instead of shift.
  3. Panel position. #helpmenu was 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%)).
  4. Panel font. #helpmenu set no font-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 in movement.js uses the standard wheel/deltaY. Only the legacy LandscapeControls.js, used by simple.html, still reads the WebKit-only wheelDelta, so it's intentionally left out of this PR.)

🤖 Generated with Claude Code

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>

@gemini-code-assist gemini-code-assist Bot 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.

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.

Comment thread cortex/webgl/resources/js/mriview.js
Comment thread cortex/webgl/resources/css/mriview.css
Comment thread cortex/webgl/resources/js/mriview.js
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>
@mvdoc mvdoc changed the title WebGL viewer: fix help-menu shortcut display & position (+ propose in-browser ROI drawing) WebGL viewer: fix help-menu shortcut display Aug 20, 2026
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
mvdoc merged commit 221bda8 into main Aug 20, 2026
12 checks passed
@mvdoc
mvdoc deleted the claude/webgl-help-menu-fixes branch August 20, 2026 21:28
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>
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.

2 participants