Skip to content

Conversation

@supersaiyansubtlety
Copy link
Member

@supersaiyansubtlety supersaiyansubtlety commented Nov 3, 2025

adds #321

based on #318

Replaces the JOptionPane dialogs opened by View > Scale > Custom (N%)... and View > Selection Highlight > Blink delay (Nms)... with custom NumberInputDialogs.


NumberInputDialogs:

  • only allow submitting ints/floats within a specified range
  • display a red border and error message when the current input is invalid
  • play the OS's error chime when invalid input is entered
  • have step up/down buttons
  • have key binds for cancel, submit, step up/down, and alt step up/down

Also:

  • gives the custom scale dialog a more informative message
  • displays any current custom scale in the Custom... menu item
  • adds @RangedFloat to Config.main().scaleFactor and reduces the max to 5 (from 10)
  • eliminates ScaleChangeListener and ScaleUtil::setScaleFactor; TrackedValue methods make them unnecessary

Notes:

  • uses custom NumberTextFields instead of JFormattedTextFields because the Formats used by JFormattedTextField are too lenient: they seem to ignore all trailing characters after valid input (including . after ints). The NumberTextFields use Integer::parseInt/Float::parseFloat; the only added leniency is trimming leading/trailing white space.
  • I considered trying to disallow entering characters that couldn't lead to valid input, but I think it could be counter intuitive (e.g. a user tries to paste a negative number at the end of the current input; it fails because a - cannot be mid-number), and it would require a custom Document which would probably require magical toolkit installation and generally increase complexity.
  • I added menu.view.scale.custom.selected translations for French and Japanese based on menu.view.scale.custom assuming the formatting would be the same as in English; I don't speak French or Japanese

Custom Scale:

initial max
scale-dialog-initial-updated scale-dialog-max-default-button
low NaN
scale-dialog-low-updated scale-dialog-nan-updated

Blink Delay:

initial min
blink-dialog-initial-updated blink-dialog-min-default-button
high NaN
blink-dialog-high-updated blink-dialog-nan-updated

@supersaiyansubtlety supersaiyansubtlety self-assigned this Nov 3, 2025
@supersaiyansubtlety supersaiyansubtlety added enhancement New feature or request user interface affects the enigma ui labels Nov 3, 2025
@supersaiyansubtlety supersaiyansubtlety linked an issue Nov 4, 2025 that may be closed by this pull request
@supersaiyansubtlety supersaiyansubtlety force-pushed the improve-number-input branch 5 times, most recently from b63d604 to 648f32c Compare November 9, 2025 20:53
@supersaiyansubtlety supersaiyansubtlety changed the base branch from develop/2.7 to develop/2.8 November 18, 2025 22:11
implement NumberInputDialog::promptFloat and use it in ScaleMenu
fix bugs related to directly setting NumberTextField's value
remove NumberInputDialog.MinimumSizeTextArea as it was unecessary
validate that step size is not greater than range size
… when it's selected (new french and japanese translations assume same formatting as english)
disable step up/down buttons on input out of range
implement alternate stepping
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request user interface affects the enigma ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve number input dialogs

1 participant