With formulars or toolbars, only EXIT or TOUCHEXIT objects can be attached at a function. When the user selects these objects, the function is invoked. Only SELECTABLE objects can be attached at a variable. If the object has the RADIO flag, the variable attached - always an integer variable - is filled with the index of the selected RADIO object at the RADIO level. If the object is not a RADIO object, the variable is filled with 1 if the object is selected, 0 else with the BIND_VAR mode. The BIND_BIT mode allows the object to be attached with a specific bit of the variable. This bit is specified by the bit parameter.
With menu, an item of the menu can be attached at a function or at a variable. When an item is linked to a variable, it is checked or unchecked when the user selects it. The variable linked is filled with 1 or 0 (or a specific bit with the BIND_BIT mode) when the item is checked or unchecked. Notice desktop menu is addressed if win parameter is set to NULL.
A function linked with to an object in a formular or a toolbar has the following interface:
void func ( WINDOW *win, int index, int mode, void *data);where win is the host window, index is the index of the attached object and mode can be OC_FORM, OC_TOOLBAR or OC_MENU. If an user data pointer is specified with ObjcAttach(), this pointer can be read as a fourth parameter of the binded function (data in our example).
A function linked to a menu object has an additionnal parameter - title - which indicated the menu title index selected. This parameter is required by MenuTNormal():
void func ( WINDOW *win, int index, int mode, int title, void *data);The fifth parameter data is an optional user pointer data specified in ObjcAttach().
{ static int radio = RAD1; #define OPTION1 0x1 /* bit 0 */ #define OPTION2 0x2 /* bit 1 */ #define OPTION3 0x4 /* bit 2 */ static int options = 0; /* Before : create the form with FormCreate() */ /* Then attach the objects */ /* 3 radio buttons in a formular */ ObjcAttach( OC_FORM, win, RAD1, BIND_VAR, &radio, 0); ObjcAttach( OC_FORM, win, RAD2, BIND_VAR, &radio, 0); ObjcAttach( OC_FORM, win, RAD3, BIND_VAR, &radio, 0); /* some checkboxes ... */ ObjcAttach( OC_FORM, win, BUT1, BIND_BIT, &options, OPTION1); ObjcAttach( OC_FORM, win, BUT2, BIND_BIT, &options, OPTION2); ObjcAttach( OC_FORM, win, BUT3, BIND_BIT, &options, OPTION3); /* An example of function linked to an object * * see after for the definition of the function */ ObjcAttach( OC_FORM, win, OK, BIND_FUNC, ButOk, 0); } /* Function linked to OK object */ void ButOk( WINDOW *win, int index, int mode) { /* Unselect the object ... */ ObjcChange( mode, win, index, NORMAL, 0); /* ... and destroy the window */ ApplWrite( app.id, WM_DESTROY, win->handle); } }