Customizable returned value on abort, and customisable headers in TerminalMenus #60065
+182
−41
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.
This PR addresses the issue of being unable to distinguish between a user aborting a
MultiSelectMenu, and selecting no items. It also adds the ability to customize the menu header. See discussion in #44012, also #43963 and #44002.Key Changes:
Configurable return value on cancel
RadioMenuandMultiSelectMenunow have anon_cancelkeyword argument. This allows you to specify the value that request returns when the menu is aborted (e.g., by pressing 'q' orCtrl-C). Ifon_cancelkeyword is not specified, the default values are-1forRadioMenuand an emptySet{Int}forMultiSelectMenu,thus ensuring backward compatibility. The recommended return value isnothing.Customizable Menu Header
The
headerkeyword argument has been added toRadioMenuandMultiSelectMenu. You can now provide a custom string, or use a boolean to enable/disable the default header. ForRadioMenu, the default is no header (backward compatible).Fields added
Each struct:
RadioMenuandMultiSelectMenuhas been extended by fieldson_cancelandheader. For backward compatibility, additional constructors has been added for each type, which take "the legacy number" of positional arguments and set the new fields to default values.This PR also includes:
Updated documentation for the new features.
Additional tests for new functionalities.