6
$\begingroup$

Consider the following TogglerBar:

selectionDialog[list_] := 
 DialogInput[{choice = {}}, 
  Column[{Row[{"Do something:"}], 
    TogglerBar[Dynamic[choice], list, Appearance -> "Vertical"], 
    Button["OK", DialogReturn[choice]]}]]

Consider some list:

list = Table["Phrase" <> (i // ToString), {i, 1, 100, 1}];

selectionDialog[list]

The given list is long, and it does not fit TogglerBar since the latter is not scrollable. Could you please tell me how to fix this issue?

$\endgroup$
3
  • $\begingroup$ Why not make a rectangular grid instead? $\endgroup$
    – Carl Woll
    Commented Aug 29, 2023 at 15:34
  • 1
    $\begingroup$ Appearance -> "Vertical" -> {5, Automatic} will produce a grid 5 rows with the required number of columns $\endgroup$
    – Bob Hanlon
    Commented Aug 29, 2023 at 15:34
  • $\begingroup$ @CarlWoll : I may have many hundreds of elements in the list. $\endgroup$ Commented Aug 29, 2023 at 15:44

1 Answer 1

10
$\begingroup$

Wrap TogglerBar with Pane and use desired settings for ImageSize and Scrollbars:

selectionDialog[list_] := 
 DialogInput[{choice = {}}, 
  Column[{Row[{"Do something:"}], 
    Pane[TogglerBar[Dynamic[choice], list, Appearance -> "Vertical"], 
     ImageSize -> {Automatic, 300}, Scrollbars -> {False, True}], 
    Button["OK", DialogReturn[choice]]}]]

list = Table["Phrase" <> (i // ToString), {i, 1, 100, 1}];

selectionDialog[list]

enter image description here

$\endgroup$
1
  • 2
    $\begingroup$ @JohnTaylor - You can put a grid inside this pane (e.g., Appearance -> "Vertical" -> {Automatic, 5}) with associated change to ImageSize. This will limit the scrolling required for large lists. $\endgroup$
    – Bob Hanlon
    Commented Aug 29, 2023 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.