First, you need to define the main(). function. This function decides if the dialog box should be opened (under which conditions) and which dialog box should be shown.

Then you can define on click functions with reactions to the selected option: onYes(), onNo(), onPrint(), onCancel().

Public properties are kept between calls. In fact, they are sent to the client and back.

User interaction script example

function main(){
// If the job is color, show a Yes/No dialog box to ask the user if they want to print the job in B&W.
if ($this->job->color){
$this->dialogYesNo("Jobs sent to this queue are printed in B&W,
do you still want to send the job here?"); }
}
function onYes(){
// The user is informed that the job was sent to the B&W queue via a MDC notification.
$this->job->owner->sendNotification("info","Job successfully sent","Your job was sent
to the B&W queue.");
}
function onNo(){
//The job is deleted and the user is informed about it via a MDC notification.
$this->job->delete(); $this->job->owner->sendNotification("info","Job deleted","Your
job was deleted.");
}