Skip to content

Fix #505: Add Enter key support for threshold inputs and ensure 2D slices update immediately#1382

Open
sh1vam31 wants to merge 1 commit intoinvesalius:masterfrom
sh1vam31:fix/505-threshold-enter-key
Open

Fix #505: Add Enter key support for threshold inputs and ensure 2D slices update immediately#1382
sh1vam31 wants to merge 1 commit intoinvesalius:masterfrom
sh1vam31:fix/505-threshold-enter-key

Conversation

@sh1vam31
Copy link
Copy Markdown
Contributor

@sh1vam31 sh1vam31 commented Apr 25, 2026

Description:

Fixes #505

This PR resolves two interconnected issues regarding the manual entry of threshold values in the "Select Region of Interest" panel

Changes:

Enter Key Support: The InvSpinCtrl and InvFloatSpinCtrl widgets previously lacked the wx.TE_PROCESS_ENTER style flag and did not handle wx.EVT_TEXT_ENTER. Users had to explicitly click away to trigger a focus-loss event to commit values. I added the necessary flags and bound the OnEnter method to successfully capture and apply the threshold when the Enter key is pressed.

Immediate 2D Slice Updates: When manually typing a value (or using the spin arrows), the OnMinMouseWheel and OnMaxMouseWheel methods in GradientCtrl only emitted a myEVT_THRESHOLD_CHANGED event. Because the myEVT_THRESHOLD_CHANGING event was skipped, the 2D slices (Axial, Coronal, Sagittal) did not visually update their colors to reflect the new mask until the user manually scrolled the viewer. I updated these methods to correctly emit both CHANGING and CHANGED events, perfectly mirroring the visual slider's behavior and forcing an immediate redraw of the 2D viewers.

Testing:

Open the application and load any dataset.
Go to the "Select Region of Interest" task panel.
Under "Mask properties", click inside either the minimum or maximum threshold text box.
Type a new value and press Enter.
Verify that the threshold slider moves immediately AND the colored mask overlay on the 2D slices instantly updates without requiring any extra mouse clicks or scrolling.

After fix:

Screen.Recording.2026-04-26.at.2.18.30.AM.mov

@sh1vam31
Copy link
Copy Markdown
Contributor Author

Hi @paulojamorim

This PR resolves issue #505 by adding wx.TE_PROCESS_ENTER and an OnEnter handler to the threshold text inputs so the Enter key works correctly.

While testing, I also noticed that manually typing a value didn't instantly update the 2D viewer colors (you had to scroll to force a refresh). I fixed this by ensuring the text inputs emit both the CHANGING and CHANGED events, so the 2D slices now update immediately, just like when using the visual slider.

Could you please review this when you have a moment?

Thanks

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.

Enter key after changing threshold value via keyboard

1 participant