November 14, 2019

Dialog class

 

Dialog class is used to generate dialogue boxes as a means of either accepting input from, or outputting information to, a user. Instances are created by sending the appropriate class message to Dialog.

Examples

Dialog warn: 'Your account is overdrawn'

Dialogue box with output: Your account is overdrawn

Message answer is nil after clicking OK.


Dialog confirm: 'Continue?'

Dialogue box with output: Continue?

Message answer is true after clicking yes.

Or false after clicking no.


Dialog request: 'Enter an amount'

Dialogue box with output: Enter an amount

Message answer is the content of the input field, a string object, after clicking OK.

Or '' , an empty string, after clicking Cancel


Dialog request: 'Enter an amount' initialAnswer: '1000'

Dialogue box with output: Your account is overdrawn

Message answer is '1000' or whatever input the user enters, after OK

Or '' , an empty string, after clicking Cancel


A few points to remember.

  • nil is an object, the only instance of the class UndefinedObject.
  • true and false are Boolean objects, the sole instances of True and False
  • '' is an empty string

There is one other Dialog class message that we need to consider.

Next page » Blocks

Previous page « Precedence

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Up to top of page