Once the layout is up and working, th program will need to perform some actions when gadget values are changed or buttons are pressed. MUI uses the DoMethod() function to do some of these actions.
MUI uses something called Notifications to do these actions, when a gadget is changed, pressed, updated or whatever a notification is produced, this can be changed using DoMethod to perform an action. The action can be to change a different gadget, call another function and so on.
The DoMethod() function looks like this:
DoMethod( object1, method, attribute, value, object2, parameter_number, method2, attribute2, value2 [,...])
For AmigaOS 4, use Intuition's IDoMethod:
IIntuition->IDoMethod(object1, method, attribute, value, object2, parameter_number, method2, attribute2, value2 [,...])
Here, if object1 receives a notification of type method e.g. MUIM_Notify, and the attribute is given a new value, then object2 is updated, a parameter_number is given (for example 3 for method, attribute and value) and the following method2 e.g. MUIM_Set, is run using the given attribute2 and value2.
You can use some of the following methods with DoMethod:
Methods | |
---|---|
Method name | Description |
MUIM_CallHook | Call a standard amiga call back hook. |
MUIM_FindUData | Finds and returns user data from an object |
MUIM_GetUData | Searches and tests if user data exists in a object |
MUIM_KillNotify | Stops notificiation messages from a given object |
MUIM_MultiSet | Sets a given attribute to a list of objects |
MUIM_NoNotifySet | Sets a given attribute but does not trigger a notify |
MUIM_Notify | Sets up a notification event handler for an object |
MUIM_Set | Sets an attribute for a object |
MUIM_SetAsString | Sets an attribute for an object using a formatted string |
MUIM_SetUData | Checks if object contains value and set attribute to a value |
Examples of DoMethod statements:
a) Call Hook Method.
DoMethod(propobj,MUIM_Notify, MUIA_Prop_First, MUIV_EveryTime,propobj,3,MUIM_CallHook,&prophook, MUIV_TriggerValue); or
IIntuition->IDoMethod(propobj,MUIM_Notify, MUIA_Prop_First, MUIV_EveryTime,propobj,3,MUIM_CallHook,&prophook, MUIV_TriggerValue);
Sets up a CallHook method for object called propobj. If the value of the attribute MUIA_Prop_First changes, then it wll call a hook defined in the prophook structure.
b) Notify method.
DoMethod(buttonobj, MUIM_Notify, MUIA_Pressed, FALSE, windowobj, 3, MUIM_Set, MUIA_Window_Open, TRUE);
or
IIntuition->IDoMethod(buttonobj, MUIM_Notify, MUIA_Pressed, FALSE, windowobj, 3, MUIM_Set, MUIA_Window_Open, TRUE);
Sets up a notification for the objec called buttonobj. When the button is pressed then it sends a notification to another object called windowobj which tells it to open its window.