Name

lcdui.command — Creates a command that can be attached to a screen

Synopsis

lcdui.command [ -label label ] [ -longlabel label ] [ -priority priority ] [ -type back | cancel | exit | help | item | ok | screen | stop ]

Description

The lcdui.command command creates a command that can be attached to a Screen or an Item. For an in-depth look at the Java code that this command is based on, see: javax.microedition.lcdui.Command

The options describing the choicegroup are as follows:

  • -label: A short label for the command, which should be as short as possible.

  • -longlabel: A long, more descriptive label.

  • -priority: A positive number indicating the order of appearance of commands, 1 being the highest priority.

  • -type: Indicates the type of command. The command types are documented here

Example

set exitcmd [lcdui.command -label Exit -longlabel Exit \
    -type exit -priority 2]
set backcmd [lcdui.command -label Back -longlabel Back \
    -type back -priority 1]
set addtextcmd [lcdui.command -label AddText -longlabel AddText \
    -type screen -priority 1]

proc NewForm {} {
    global exitcmd
    global backcmd
    global addtextcmd
    set form [lcdui.form -title "Commands" -commandaction HandleCmd]
    $form setcurrent
    $form addcommand $exitcmd
    $form addcommand $backcmd
    $form addcommand $addtextcmd
}

proc HandleCmd {cmd form} {
   global exitcmd
   global backcmd
   if { eq $cmd $backcmd } {
   	NewForm
   } elseif { eq $cmd $exitcmd } {
   	[lcdui.alert -title "Goodbye" -text "Goodbye!" -type info \
            -timeout forever] setcurrent
        after 1000 midlet.exit
   }
   $form append "Blah blah"
}

NewForm
	  

Live example: http://www.heclbuilder.com/scripts/show/144