Programming morphs - page 9 - user queries
Last updated at 5:31 pm UTC on 30 June 2018
Finally, it is often useful to ask the user for a small amount of information before proceding.
The simplest way to ask is to pop up a text window and ask the user to submit a response. This can be done using class FillInTheBlank:
FillInTheBlank request: 'What is your name?' initialAnswer: 'Jean'
Often, instead of requiring a user to type in a text response, it is possible to let them choose from all possible alternatives in a menu. There are many varieties of menus in Squeak; one of the simplest is the PopUpMenu, which is used as below:
menu :=
PopUpMenu
labelArray: #(
'red'
'blue'
'green'
'cyan'
'magenta'
'yellow'
'white'
'black')
lines: #(3 6 8).
menu startUpWithCaption: 'Pick a color' 6