Widget callbacks » History » Version 15
iri, 03/02/2011 12:29 AM
1 | 1 | iri | h1. Widget callbacks |
---|---|---|---|
2 | |||
3 | A signal will be emitted when an event occurs on a widget. |
||
4 | To run any actions when a signal is emitted, you should define a _callback_, a function will run these actions. |
||
5 | |||
6 | Here, you can define all callbacks with an one function : *_gtkWidgetCB* |
||
7 | |||
8 | Its prototype is : *fun [ObjGtkWidget u1 u0 I I] ObjGtkWidget* |
||
9 | |||
10 | # *ObjGtkWidget* : Scol object : the widget |
||
11 | # *u1* : the prototype of the callback (see below) |
||
12 | # *u0* : the user parameter, at your convenience |
||
13 | # *I* : the flag of the callback = which signal is affected ? (see below) |
||
14 | # *I* : the mask : propagate or not the signal to the container ? Two values are availables |
||
15 | * SCOL_GTK_SIGNAL_MASK_PROPAGATE |
||
16 | * SCOL_GTK_SIGNAL_MASK_STOP |
||
17 | |||
18 | +Warning+ : the prototype of the callback is different for each flag ! |
||
19 | |||
20 | Flag currently availables : |
||
21 | |||
22 | 11 | iri | {{toc}} |
23 | 5 | iri | |
24 | 7 | iri | h1. Any widgets |
25 | |||
26 | 1 | iri | h2. SCOL_GTK_WIDGET_BUTTONPRESSED |
27 | |||
28 | a mouse button has been pressed on a widget. |
||
29 | Prototype : *fun [ObjGtkWidget u0 I I I [I I]] u2* |
||
30 | |||
31 | |||
32 | 3 | iri | table |
33 | |1. *widget*|ObjGtkWidget|a widget| | |
||
34 | |2. *userparam*|u0|a user parameter, at your convenience| | |
||
35 | |3. *signal*|I|the type of the signal|SCOL_GTK_EVENT_BUTTON_PRESSED (one click),| |
||
36 | | | | |SCOL_GTK_EVENT_BUTTON_PRESSED2 (double click),| |
||
37 | | | | |SCOL_GTK_EVENT_BUTTON_PRESSED3 (triple click),| |
||
38 | | | | |SCOL_GTK_EVENT_BUTTON_RELEASE (button released).| |
||
39 | | | | |So you can make one function to several definitions| |
||
40 | |4. *button*|I|the mouse button|SCOL_GTK_EVENT_BUTTON_1,| |
||
41 | | | | |SCOL_GTK_EVENT_BUTTON_2,| |
||
42 | | | | |SCOL_GTK_EVENT_BUTTON_3,| |
||
43 | | | | |SCOL_GTK_EVENT_BUTTON_4,| |
||
44 | | | | |SCOL_GTK_EVENT_BUTTON_5,| |
||
45 | |5. *mask*|I|the mask of the modifier keys|SCOL_GTK_EVENT_KEY_SHIFT| |
||
46 | | | | |SCOL_GTK_EVENT_KEY_CONTROL,| |
||
47 | | | | |SCOL_GTK_EVENT_KEY_ALT,| |
||
48 | 4 | iri | | | | |SCOL_GTK_EVENT_KEY_CAPS (can not work : system, window manager, ...)| |
49 | | | | |SCOL_GTK_EVENT_KEY_HYPER (can not work : system, window manager, ...)| |
||
50 | | | | |SCOL_GTK_EVENT_KEY_SUPER (can not work : system, window manager, ...)| |
||
51 | 3 | iri | | | | |SCOL_GTK_EVENT_KEY_OTHER (or nothing)| |
52 | |6. *position*|I|the position of the click [x y], relative to the widget| | |
||
53 | 1 | iri | |
54 | 14 | iri | 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). |
55 | 1 | iri | |
56 | 13 | iri | |
57 | 3 | iri | h2. SCOL_GTK_WIDGET_BUTTONRELEASED |
58 | 1 | iri | |
59 | 3 | iri | a mouse button has been released on a widget. |
60 | Prototype : *fun [ObjGtkWidget u0 I I I [I I]] u2* |
||
61 | 1 | iri | |
62 | 14 | iri | 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). |
63 | 13 | iri | |
64 | 3 | iri | See 'SCOL_GTK_WIDGET_BUTTONPRESSED' above. |
65 | 5 | iri | |
66 | h2. SCOL_GTK_WIDGET_MOVERESIZE |
||
67 | |||
68 | a window has moved and/or resized. |
||
69 | Prototype : *fun [ObjGtkWidget u0 [I I] [I I]] u2* |
||
70 | |||
71 | The supplementals parameters are two tuples : |
||
72 | # is the new position (x and y, relative at its parents or at the screen) |
||
73 | # is the new size (width and height) |
||
74 | 1 | iri | |
75 | 6 | iri | h2. SCOL_GTK_WIDGET_DESTROY |
76 | |||
77 | when a widget (typically a window or all top level container) is destroyed (all reference are destroyed). |
||
78 | Prototype : *fun [ObjGtkWidget u0] u2* |
||
79 | |||
80 | 8 | iri | h2. SCOL_GTK_WIDGET_ENTERLEAVE |
81 | |||
82 | when the pointer (typically a mouse) enter or leave a window (maybe an other object) |
||
83 | Prototype : *fun [ObjGtkWidget u0 I I I [I I]] u2* |
||
84 | |||
85 | The supplementals arguments are : |
||
86 | table |
||
87 | |1. *widget*|ObjGtkWidget|a widget (typically a window)| | |
||
88 | |2. *userparam*|u0|a user parameter, at your convenience| | |
||
89 | |3 *type*|I|the pointer enters or leaves|0 if enters, 1 if leaves| |
||
90 | |4 *mask*|I|the mask of the modifier keys|SCOL_GTK_EVENT_KEY_SHIFT| |
||
91 | | | | |SCOL_GTK_EVENT_KEY_CONTROL,| |
||
92 | | | | |SCOL_GTK_EVENT_KEY_ALT,| |
||
93 | | | | |SCOL_GTK_EVENT_KEY_CAPS (can not work : system, window manager, ...)| |
||
94 | | | | |SCOL_GTK_EVENT_KEY_HYPER (can not work : system, window manager, ...)| |
||
95 | | | | |SCOL_GTK_EVENT_KEY_SUPER (can not work : system, window manager, ...)| |
||
96 | | | | |SCOL_GTK_EVENT_KEY_OTHER (or nothing)| |
||
97 | |5 *focus*|I|the widget has (or not) the focus|1 if is the focus window or an inferior| |
||
98 | |6 *coord*|[I I]|the coordinate of the pointer (x, y)| |
||
99 | |||
100 | 9 | iri | h2. SCOL_GTK_WIDGET_KEYB_FOCUS |
101 | |||
102 | when the keyboard focus enters or leaves a widget. |
||
103 | Prototype : *fun [ObjGtkWidget u0 I] u2* |
||
104 | |||
105 | The supplemental parameter is : |
||
106 | *in* : I : 1 if enter, 0 if lost |
||
107 | |||
108 | 10 | iri | h2. SCOL_GTK_WIDGET_SHOW |
109 | |||
110 | when a widget is shown |
||
111 | Prototype : *fun [ObjGtkWidget u0] u2* |
||
112 | |||
113 | h2. SCOL_GTK_WIDGET_HIDE |
||
114 | |||
115 | when a widget is hidden |
||
116 | Prototype : *fun [ObjGtkWidget u0] u2* |
||
117 | 9 | iri | |
118 | 12 | iri | h2. SCOL_GTK_WIDGET_KEY |
119 | |||
120 | when a key is pressed or released |
||
121 | Prototype : *fun [ObjGtkWidget u0 I I I S] u2* |
||
122 | |||
123 | table |
||
124 | |1. *widget*|ObjGtkWidget|a widget| | |
||
125 | |2. *userparam*|u0|a user parameter, at your convenience| | |
||
126 | 15 | iri | |3. *type*|I|the keyis pressed or released|0 if pressed, 1 if released, nil if not known, error, etc| |
127 | |4. *mask*|I|the mask of the modifier keys|SCOL_GTK_EVENT_KEY_SHIFT| |
||
128 | 12 | iri | | | | |SCOL_GTK_EVENT_KEY_CONTROL,| |
129 | | | | |SCOL_GTK_EVENT_KEY_ALT,| |
||
130 | | | | |SCOL_GTK_EVENT_KEY_CAPS (can not work : system, window manager, ...)| |
||
131 | | | | |SCOL_GTK_EVENT_KEY_HYPER (can not work : system, window manager, ...)| |
||
132 | | | | |SCOL_GTK_EVENT_KEY_SUPER (can not work : system, window manager, ...)| |
||
133 | | | | |SCOL_GTK_EVENT_KEY_OTHER (or nothing)| |
||
134 | 1 | iri | |5 *keyval*|I|the value of the key|| |
135 | |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.| |
||
136 | 15 | iri | |
137 | h2. SCOL_GTK_WIDGET_MOTION |
||
138 | |||
139 | when the pointer moves over a widget |
||
140 | Prototype : *fun [ObjGtkWidget u0 I [I I] [I I] [S I]] u2* |
||
141 | |||
142 | table |
||
143 | |1. *widget*|ObjGtkWidget|a widget| | |
||
144 | |2. *userparam*|u0|a user parameter, at your convenience| | |
||
145 | |3. *mask*|I|the mask of the modifier keys|SCOL_GTK_EVENT_KEY_SHIFT| |
||
146 | | | | |SCOL_GTK_EVENT_KEY_CONTROL,| |
||
147 | | | | |SCOL_GTK_EVENT_KEY_ALT,| |
||
148 | | | | |SCOL_GTK_EVENT_KEY_CAPS (can not work : system, window manager, ...)| |
||
149 | | | | |SCOL_GTK_EVENT_KEY_HYPER (can not work : system, window manager, ...)| |
||
150 | | | | |SCOL_GTK_EVENT_KEY_SUPER (can not work : system, window manager, ...)| |
||
151 | | | | |SCOL_GTK_EVENT_KEY_OTHER (or nothing)| |
||
152 | |4. *coord*|[I I]|x and y coordinates| | |
||
153 | |5. *coorddevice*|[I I]|x, y translated to the axes of device, or nil if device is the mouse| | |
||
154 | |6. *device*|[S I]|the name of the device and the type of the device| | |
||
155 | 13 | iri | |
156 | |||
157 | h1. Any button |
||
158 | |||
159 | 14 | iri | h2. SCOL_GTK_BUTTON_CLICKED |
160 | 13 | iri | |
161 | A button has been clicked |
||
162 | Prototype : *fun [ObjGtkWidget u0] u2* |
||
163 | |||
164 | |||
165 | 12 | iri | |
166 | 6 | iri | |
167 | 1 | iri | Return [[Widgets]] |