Action Statement
Create a new object, action bar item, or plate during runtime.
For Objects and Items:
add {ITEM_DEF|OBJECT_DEF}
For Action Bar Templates:
add action bar AB_NAME is
[PULLDOWN_DEF_OR_REF] ...
[BUTTON_DEF_OR_REF] ...
end action bar
ITEM_DEF
The definition for a pulldown, button, choice, or separator.
OBJECT_DEF
The definition for an object.
AB_NAME
The identifier for an action bar template.
PULLDOWN_DEF_OR_REF
The definition for, or reference to, a pulldown.
BUTTON_DEF_OR_REF
The definition for, or reference to, a button.
Description
The new object is created when the add statement is executed.
When using this statement, be careful to ensure that the identifier specified is unique. To minimize the risk of duplicating identifiers, specify a variable whose value is the identifier, rather than specifying an explicit name, in the add statement.
You can use an item reference to reference any item that you have defined outside of an action bar template.
Only regions that are children of the desktop can have action bars.
Examples
response to GoBack
add key NewChoice_KEY at position 10 10
solid red box 100 20
move to 50 10
text "ABANDON SCREEN"
response to OpenWriter
add textual region Blackboard_TR
window size 10 columns 10 lines
at position 10 200 in GraphArea
response to NewMessage
add action bar Mail_Window_AB is
pulldown Exit_Choices text "E~xit"
choice Exit text "~Exit"
choice Resume text "~Resume Mail"
end pulldown
end action bar
add color 26 graphical region Mail_Window_GR
size 263 160
at position 60 80
in desktop
color 27 foreground
size border
title bar "Mail"
system menu
horizontal scroll bar scroll by 6
vertical scroll bar scroll by 16
no scale
action bar Mail_Window_AB
# The following code dynamically builds an action bar
# with pulldowns and choices.
#
string ActionBar_SV
PullDown_SV
PullDownText_SV
Choice_SV
ChoiceText_SV
response to start
copy "Attribute_AB" to ActionBar_SV
copy "Material_PD" to PullDown_SV
copy "Material <~S>" to PullDownText_SV
copy "Glass_MC" to Choice_SV
copy "10 Glass" to ChoiceText_SV #Continued
# Dynamically create an action bar.
add action bar ActionBar_SV is
end action bar
# Dynamically create a text region, with the newly created
# action bar.
add color 26 primary graphical region Text_Window_CR
size 200 200
at 100 100
in desktop
title bar "Dynamic Action Bars"
system menu
action bar ActionBar_SV
# Dynamically create a pulldown.
add pulldown PullDown_SV text PullDownText_SV
end pulldown
# Dynamically add the pulldown to an action bar.
add item PullDown_SV to action bar in Text_Window_CR
# Dynamically create a choice.
add choice Choice_SV text ChoiceText_SV
# Dynamically add the choice to a pulldown.
add item Choice_SV to pulldown PullDown_SV in Text_Window_CR
See Also
Object definition statements