Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting default selections in TerminalMenus #30043

Closed
wants to merge 1 commit into from
Closed

Allow setting default selections in TerminalMenus #30043

wants to merge 1 commit into from

Conversation

christopher-dG
Copy link
Member

@christopher-dG christopher-dG commented Nov 14, 2018

This doesn't change any behaviour without opting into it with the default keyword, but allows you to set the initial cursor position (for RadioMenu) or checked options (MultiSelectMenu) when request is called.

Example (the menus are what appear without any input):

julia> m = RadioMenu(["a", "b", "c", "d", "e"]; default=3);

julia> request(m)
   a
   b
 > c
   d
   e
3

julia> m = MultiSelectMenu(["a", "b", "c", "d", "e"]; default=[2, 4]);

julia> request(m)
[press: d=done, a=all, n=none]
 > [ ] a
   [X] b
   [ ] c
   [X] d
   [ ] e
Set([4, 2])

@KronosTheLate
Copy link
Contributor

Note that this is implemented. Example below:

julia> import REPL; using REPL.TerminalMenus

julia> menu = MultiSelectMenu(["Op 1", "Op 2", "Op 3"], selected=(2, 3));

julia> request(menu)
[press: Enter=toggle, a=all, n=none, d=done, q=abort]
 > [ ] Op 1
   [X] Op 2
   [X] Op 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants