GenTrigger: 2 GenTrigger Usage

Up: GEOS SDK TechDocs | Up | Prev: 1 GenTrigger Overview | Next: 3 Supplemental GenTrigger Usage

A simple GenTrigger should contain a message to send out upon activation, a destination to send the message to, and a visual moniker to distinguish the trigger from other objects (and describe its function to the user).

You may use the prototype GEN_TRIGGER_ACTION to define the action message. This prototype passes the optr of the sending trigger in the variable name `trigger' and can be accessed within a message handler.

GenTriggers may appear within GenPrimarys, GenViews, or, most often, within a GenInteraction. If a GenTrigger is placed as a child of a GIV_POPUP GenInteraction, the GenTriggers may be represented as menu items.

Code Display 5-2 Code for Basic GenTriggers

/* Use the prototype GEN_TRIGGER_ACTION to define a GenTrigger's action message. 
 * Within a method, you can retrieve this optr with the variable name `trigger.' */
@message (GEN_TRIGGER_ACTION) MSG_HELLO_CHANGE_TO_BLUE();
@message (GEN_TRIGGER_ACTION) MSG_HELLO_CHANGE_TO_GOLD();
/* The GenInteraction object will contain the child GenTriggers. */
@object GenInteractionClass HelloColorBox = {
    GI_comp = @HelloBlueTrigger, @HelloGoldTrigger;
    GI_visMoniker = 'C', "Color";
    GII_visibility = GIV_DIALOG;
}
/* GenTriggers
 * Buttons are implemented by GenTriggerClass. When the trigger is pushed by
 * the user (clicked on with the mouse), it will send the specified message
 * to the specified destination object. In both cases below, the trigger will
 * send an application-defined message to the application's Process
 * object. A trigger's moniker is displayed within the trigger. In this
 * case both are text, but any graphics string could also be used to create
 * graphical triggers. */
@object GenTriggerClass HelloBlueTrigger = {
    GI_visMoniker = 'B', "Blue";
	/* Send MSG_HELLO_CHANGE_TO_BLUE to the Process object. */
    GTI_destination = process;
    GTI_actionMsg = MSG_HELLO_CHANGE_TO_BLUE;
}
@object GenTriggerClass HelloGoldTrigger = {
    GI_visMoniker = 'G', "Gold";
	/* Send MSG_HELLO_CHANGE_TO_GOLD to the Process object. */
    GTI_destination = process;
    GTI_actionMsg = MSG_HELLO_CHANGE_TO_GOLD;
}

Up: GEOS SDK TechDocs | Up | Prev: 1 GenTrigger Overview | Next: 3 Supplemental GenTrigger Usage