Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
Using dialog boxes in your user interface can make things clean and easy for the users. There are standard dialogs and custom dialogs that can be used for things such as warning messages or user input. Customizing a dialog box allows you to make the dialog box as specific as you want for its designated purpose.
Standard Dialog Boxes: Standard dialog boxes are easy to create and only require a few lines of code. These are good for displaying warning messages and taking in input from the user.
Warning Messages: Warning messages are simple text messages that warn the user when a particular action cannot be completed. A warning message sends a warn: message to the Dialog class provided for you. When the user clicks OK, a nil value is returned. Use the following code as an example for creating a warning message:
returnVal := Dialog
warn: ‘My Warning.’
Self returnedValue value: returnVal printString.
Warning dialog boxes are a great way to warn the user when they have entered incorrect data. These can be very helpful in making your program as user friendly as possible, and to get good remarks during your UI Evaluation.
Confirmers (Yes/No Dialogs): Confirmers are used to verify if a user wishes to continue an action that may have unseen consequences. Confirmers send a confirm: message to the Dialog class. When the user clicks YES the dialog returns true, and false when the user clicks NO. Be careful because the default answer is YES. Use the following code as an example for creating a confirmer that changes the default answer:
confirm: ‘Are you sure you want to quit without saving?’
Confirmers are the best way to question a user’s selection. It can also be a good way to see if the user wants to exit the program without saving.
Textual Response Dialogs: Textual Response dialogs are useful for short text inputs from the user. These dialog boxes have an input field and a prompt. In response dialogs, a request: message is sent to the Dialog class. When the user clicks OK, the specified string is returned to the application. When the user clicks Cancel, an empty string is sent by default. The default string appears in the input field until changed by the user. The default string can be changed. Use the following code as an example to create your own response dialog:
returnVal := Dialog
request: ‘Enter your name’
onCancel: [ ].
Self returnedValued value: returnVal printString.
Response dialogs are the solution to getting user input for your program.
Multiple Selection Dialogs: Multiple Selection dialogs provide the user with a list from which to select an item. The multiple selection dialog sends the following messages to the Dialog class: choose:, fromList:, values:, lines:, and cancel:. You can use the following code as an example to create your own Multiple Selection dialog box:
files := Filename defaultDirectory directoryContents
reject: [ :name | name asFilename isDirectory].
response := Dialog
choose: 'Which card do you want to edit'
response asFilename edit.
Multiple Selection dialog boxes are a great way to give the user a list to select options from without having to enter data manually, which could cause incorrect data entry.
Links to this Page
- Cases last edited on 30 July 2011 at 2:33 am by r59h132.res.gatech.edu
- Index of Individual Cases last edited on 3 May 2011 at 12:46 pm by r52h48.res.gatech.edu