Project

General

Profile

Widget callbacks » History » Revision 20

Revision 19 (iri, 03/02/2011 11:53 PM) → Revision 20/26 (iri, 03/03/2011 12:04 AM)

h1. Widget callbacks 

 A signal will be emitted when an event occurs on a widget. 
 To run any actions when a signal is emitted, you should define a _callback_, a function will run these actions. 

 Here, you can define all callbacks with an one function : *_gtkWidgetCB* 

 Its prototype is : *fun [ObjGtkWidget u1 u0 I I] ObjGtkWidget* 

 # *ObjGtkWidget* : Scol object : the widget 
 # *u1* : the prototype of the callback (see below) 
 # *u0* : the user parameter, at your convenience 
 # *I* : the flag of the callback = which signal is affected ? (see below) 
 # *I* : the mask : propagate or not the signal to the container ? Two values are availables 
 * SCOL_GTK_SIGNAL_MASK_PROPAGATE 
 * SCOL_GTK_SIGNAL_MASK_STOP 

 +Warning+ : the prototype of the callback (u1) is different for each flag ! 

 Flag currently availables : 

 {{toc}} 

 h1. Any widgets 

 h2. SCOL_GTK_WIDGET_BUTTONPRESSED 

 a mouse button has been pressed on a widget. 
 Prototype : *fun [ObjGtkWidget u0 I I I [I I]] u2* 


 table 
 |1. *widget*|ObjGtkWidget|a widget| | 
 |2. *userparam*|u0|a user parameter, at your convenience| | 
 |3. *signal*|I|the type of the signal|SCOL_GTK_EVENT_BUTTON_PRESSED (one click),| 
 | | | |SCOL_GTK_EVENT_BUTTON_PRESSED2 (double click),| 
 | | | |SCOL_GTK_EVENT_BUTTON_PRESSED3 (triple click),| 
 | | | |SCOL_GTK_EVENT_BUTTON_RELEASE (button released).| 
 | | | |So you can make one function to several definitions| 
 |4. *button*|I|the mouse button|SCOL_GTK_EVENT_BUTTON_1,| 
 | | | |SCOL_GTK_EVENT_BUTTON_2,| 
 | | | |SCOL_GTK_EVENT_BUTTON_3,| 
 | | | |SCOL_GTK_EVENT_BUTTON_4,| 
 | | | |SCOL_GTK_EVENT_BUTTON_5,| 
 |5. *mask*|I|the mask of the modifier keys|SCOL_GTK_EVENT_KEY_SHIFT| 
 | | | |SCOL_GTK_EVENT_KEY_CONTROL,| 
 | | | |SCOL_GTK_EVENT_KEY_ALT,| 
 | | | |SCOL_GTK_EVENT_KEY_CAPS (can not work : system, window manager, ...)| 
 | | | |SCOL_GTK_EVENT_KEY_HYPER (can not work : system, window manager, ...)| 
 | | | |SCOL_GTK_EVENT_KEY_SUPER (can not work : system, window manager, ...)| 
 | | | |SCOL_GTK_EVENT_KEY_OTHER (or nothing)| 
 |6. *position*|I|the position of the click [x y], relative to the widget| | 

 Note : sometimes, it is better to use the flag "SCOL_GTK_BUTTON_CLICKED":http://trac.scolring.org/projects/lib2dgtk/wiki/Widget_callbacks#SCOL_GTK_BUTTON_CLICKED. For example, to grab the signal of a mnemonic button, SCOL_GTK_BUTTON_CLICKED should be used (but the callback give less informations). 


 h2. SCOL_GTK_WIDGET_BUTTONRELEASED 

 a mouse button has been released on a widget. 
 Prototype : *fun [ObjGtkWidget u0 I I I [I I]] u2* 

 Note : sometimes, it is better to use the flag "SCOL_GTK_BUTTON_CLICKED":http://trac.scolring.org/projects/lib2dgtk/wiki/Widget_callbacks#SCOL_GTK_BUTTON_CLICKED. For example, to grab the signal of a mnemonic button, SCOL_GTK_BUTTON_CLICKED should be used (but the callback give less informations). 

 See 'SCOL_GTK_WIDGET_BUTTONPRESSED' above. 

 h2. SCOL_GTK_WIDGET_MOVERESIZE 

 a window has moved and/or resized. 
 Prototype : *fun [ObjGtkWidget u0 [I I] [I I]] u2* 

 The supplementals parameters are two tuples : 
 # is the new position (x and y, relative at its parents or at the screen) 
 # is the new size (width and height) 

 h2. SCOL_GTK_WIDGET_DESTROY 

 when a widget (typically a window or all top level container) is destroyed (all reference are destroyed). 
 Prototype : *fun [ObjGtkWidget u0] u2* 

 h2. SCOL_GTK_WIDGET_ENTERLEAVE 

 when the pointer (typically a mouse) enter or leave a window (maybe an other object) 
 Prototype : *fun [ObjGtkWidget u0 I I I [I I]] u2* 

 The supplementals arguments are : 
 table 
 |1. *widget*|ObjGtkWidget|a widget (typically a window)| | 
 |2. *userparam*|u0|a user parameter, at your convenience| | 
 |3 *type*|I|the pointer enters or leaves|0 if enters, 1 if leaves| 
 |4 *mask*|I|the mask of the modifier keys|SCOL_GTK_EVENT_KEY_SHIFT| 
 | | | |SCOL_GTK_EVENT_KEY_CONTROL,| 
 | | | |SCOL_GTK_EVENT_KEY_ALT,| 
 | | | |SCOL_GTK_EVENT_KEY_CAPS (can not work : system, window manager, ...)| 
 | | | |SCOL_GTK_EVENT_KEY_HYPER (can not work : system, window manager, ...)| 
 | | | |SCOL_GTK_EVENT_KEY_SUPER (can not work : system, window manager, ...)| 
 | | | |SCOL_GTK_EVENT_KEY_OTHER (or nothing)| 
 |5 *focus*|I|the widget has (or not) the focus|1 if is the focus window or an inferior| 
 |6 *coord*|[I I]|the coordinate of the pointer (x, y)| 

 h2. SCOL_GTK_WIDGET_KEYB_FOCUS 

 when the keyboard focus enters or leaves a widget. 
 Prototype : *fun [ObjGtkWidget u0 I] u2* 

 The supplemental parameter is : 
 *in* : I : 1 if enter, 0 if lost 

 h2. SCOL_GTK_WIDGET_SHOW 

 when a widget is shown 
 Prototype : *fun [ObjGtkWidget u0] u2* 

 h2. SCOL_GTK_WIDGET_HIDE 

 when a widget is hidden 
 Prototype : *fun [ObjGtkWidget u0] u2* 

 h2. SCOL_GTK_WIDGET_KEY 

 when a key is pressed or released 
 Prototype : *fun [ObjGtkWidget u0 I I I S] u2* 

 table 
 |1. *widget*|ObjGtkWidget|a widget| | 
 |2. *userparam*|u0|a user parameter, at your convenience| | 
 |3. *type*|I|the keyis pressed or released|0 if pressed, 1 if released, nil if not known, error, etc| 
 |4. *mask*|I|the mask of the modifier keys|SCOL_GTK_EVENT_KEY_SHIFT| 
 | | | |SCOL_GTK_EVENT_KEY_CONTROL,| 
 | | | |SCOL_GTK_EVENT_KEY_ALT,| 
 | | | |SCOL_GTK_EVENT_KEY_CAPS (can not work : system, window manager, ...)| 
 | | | |SCOL_GTK_EVENT_KEY_HYPER (can not work : system, window manager, ...)| 
 | | | |SCOL_GTK_EVENT_KEY_SUPER (can not work : system, window manager, ...)| 
 | | | |SCOL_GTK_EVENT_KEY_OTHER (or nothing)| 
 |5 *keyval*|I|the value of the key|| 
 |6 *keystring*|S|the string (e.g. if keyval = 65, keystring = "A").|But, be careful, if the key is the left shift, keystring should be "SHIFT_L", or, in french, with the key รจ, keystring = "egrave", ... This last argument is a facility only.| 

 h2. SCOL_GTK_WIDGET_MOTION 

 when the pointer moves over a widget 
 Prototype : *fun [ObjGtkWidget u0 I [I I] [I I] [S I]] u2* 

 table 
 |1. *widget*|ObjGtkWidget|a widget| | 
 |2. *userparam*|u0|a user parameter, at your convenience| | 
 |3. *mask*|I|the mask of the modifier keys|SCOL_GTK_EVENT_KEY_SHIFT| 
 | | | |SCOL_GTK_EVENT_KEY_CONTROL,| 
 | | | |SCOL_GTK_EVENT_KEY_ALT,| 
 | | | |SCOL_GTK_EVENT_KEY_CAPS (can not work : system, window manager, ...)| 
 | | | |SCOL_GTK_EVENT_KEY_HYPER (can not work : system, window manager, ...)| 
 | | | |SCOL_GTK_EVENT_KEY_SUPER (can not work : system, window manager, ...)| 
 | | | |SCOL_GTK_EVENT_KEY_OTHER (or nothing)| 
 |4. *coord*|[I I]|x and y coordinates| | 
 |5. *coorddevice*|[I I]|x, y translated to the axes of device, or nil if device is the mouse| | 
 |6. *device*|[S I]|the name of the device and the type of the device|In *Gtk+ 2.x*, the string is always "unknown" and the integer is always SCOL_DEVICE_UNKNOWN| 
 | | | |SCOL_DEVICE_MOUSE,| 
 | | | |SCOL_DEVICE_PEN,| 
 | | | |SCOL_DEVICE_ERASER,| 
 | | | |SCOL_DEVICE_CURSOR,| 
 | | | |SCOL_DEVICE_KEYBOARD,| 
 | | | |SCOL_DEVICE_UNKNOWN| 

 h2. SCOL_GTK_WIDGET_SCROLL 

 when the whell mouse turns and or is pressed 

 Prototype : *fun [ObjGtkWidget u0 I I [I I] [S I]] u2* 
 table 
 |1. *widget*|ObjGtkWidget|a widget| | 
 |2. *userparam*|u0|a user parameter, at your convenience| | 
 |3. *direction*|I|the direction|SCOL_GTK_EVENT_SCROLL_UP| 
 | | | |SCOL_GTK_EVENT_SCROLL_DOWN| 
 | | | |SCOL_GTK_EVENT_SCROLL_LEFT| 
 | | | |SCOL_GTK_EVENT_SCROLL_RIGHT| 
 | | | |SCOL_GTK_EVENT_SCROLL_UNKNOWN| 
 |4. *mask*|I|the mask of the modifier keys|SCOL_GTK_EVENT_KEY_SHIFT| 
 | | | |SCOL_GTK_EVENT_KEY_CONTROL,| 
 | | | |SCOL_GTK_EVENT_KEY_ALT,| 
 | | | |SCOL_GTK_EVENT_KEY_CAPS (can not work : system, window manager, ...)| 
 | | | |SCOL_GTK_EVENT_KEY_HYPER (can not work : system, window manager, ...)| 
 | | | |SCOL_GTK_EVENT_KEY_SUPER (can not work : system, window manager, ...)| 
 | | | |SCOL_GTK_EVENT_KEY_OTHER (or nothing)| 
 |5. *coord*|[I I]|x and y coordinates| | 
 |6. *device*|[S I]|the name of the device and the type of the device|In *Gtk+ 2.x*, the string is always "unknown" and the integer is always SCOL_DEVICE_UNKNOWN| 
 | | | |SCOL_DEVICE_MOUSE,| 
 | | | |SCOL_DEVICE_PEN,| 
 | | | |SCOL_DEVICE_ERASER,| 
 | | | |SCOL_DEVICE_CURSOR,| 
 | | | |SCOL_DEVICE_KEYBOARD,| 
 | | | |SCOL_DEVICE_UNKNOWN| 



 h1. Window only 

 h2. SCOL_GTK_WINDOW_STATE 

 when the state of a window changes. 

 Prototype : *fun [ObjGtkWidget u0 I] u2* 

 table 
 |1. *widget*|ObjGtkWidget|a widget|Warning : widget *must* be a window (GtkWindow, see "_gtkWidgetTypeName":http://trac.scolring.org/projects/lib2dgtk/wiki/Widgets)| 
 |2. *userparam*|u0|a user parameter, at your convenience| | 
 |3. *state*|I|what flags have changed ?|SCOL_WINDOW_NOTSHOWN the window is not shown| 
 | | | |SCOL_WINDOW_ICONIFIED the window is minimized| 
 | | | |SCOL_WINDOW_MAXIMIZED the window is maximized| 
 | | | |SCOL_WINDOW_STICKY the window is sticky| 
 | | | |SCOL_WINDOW_FULLSCREEN the window is maximized without decorations| 
 | | | |SCOL_WINDOW_ABOVE the window is kept above other windows| 
 | | | |SCOL_WINDOW_BELOW the window is kept below other windows| 
 | | | |SCOL_WINDOW_STATE_UNKNOWN the state is unknown| 




 h1. Button only 

 h2. SCOL_GTK_BUTTON_CLICKED 

 A button has been clicked 
 Prototype : *fun [ObjGtkWidget u0] u2* 
 Warning : widget *must* be a button (GtkButton, see "_gtkWidgetTypeName":http://trac.scolring.org/projects/lib2dgtk/wiki/Widgets) 



 Return [[Widgets]]