1

Consider some test list that I call LongList:

LongList = Table["Some very-very long name", 300];

I would like to use ChoiceDialog to associate some parameter with an element of the list.

parameter = 
 ChoiceDialog["Choose the experiment:", LongList, 
  Appearance -> "Vertical" -> {Automatic, 1}]

This does not work properly: the dialog window has fixed height, and it is impossible to scroll, so the list does not fit the window: enter image description here

If changing Appearance -> "Vertical" -> {Automatic, 1} to Appearance -> "Vertical" -> {Automatic, 10}, I do not fix the problem but gain an additional one instead, coming from the fact that the width of the window stays the same. As a result, 1) only 4 buttons match the window, and 2) the buttons cannot be wide enough to fit the list elements properly: enter image description here

The documentation on ChoiceDialog is very poor and does not include any description about changing its design.

Could you please tell me how to fix this problem (either allow scrolling down or scrolling left-right, with wide enough buttons)?

Domen
  • 23,608
  • 1
  • 27
  • 45
John Taylor
  • 5,701
  • 2
  • 12
  • 33

1 Answers1

6

From UX perspective, I strongly suggest using a drop-down menu with PopupMenu instead. The code below works the same as ChoiceDialog: It opens a pop-up dialog, then returns the selected value.

dropdownDialog[list_] := 
 DialogInput[{choice = ""}, 
  Column[{PopupMenu[Dynamic[choice], list], 
    Button["OK", DialogReturn[choice]]}]]

dropdownDialog[LongList]

enter image description here

If you insist on buttons, you can use DialogNotebook with "VerticalScrollBar".

buttonsDialog[list_] := 
  DialogInput[
   DialogNotebook[
    Grid[Partition[
      Table[With[{opt = opt}, 
        Button[opt, DialogReturn[opt], ImageSize -> Automatic]], {opt,
         LongList}], 4]]], WindowElements -> {"VerticalScrollBar"}, 
   WindowSize -> Medium];

buttonsDialog[LongList]

enter image description here

Domen
  • 23,608
  • 1
  • 27
  • 45