Project

General

Profile

Widget callbacks » History » Version 23

iri, 03/23/2011 09:03 PM

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 20 iri
+Warning+ : the prototype of the callback (u1) is different for each flag !
19 1 iri
20 21 iri
Flags currently availables :
21 1 iri
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 16 iri
|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|
155
| | | |SCOL_DEVICE_MOUSE,|
156
| | | |SCOL_DEVICE_PEN,|
157
| | | |SCOL_DEVICE_ERASER,|
158
| | | |SCOL_DEVICE_CURSOR,|
159
| | | |SCOL_DEVICE_KEYBOARD,|
160
| | | |SCOL_DEVICE_UNKNOWN|
161 13 iri
162 17 iri
h2. SCOL_GTK_WIDGET_SCROLL
163
164
when the whell mouse turns and or is pressed
165
166
Prototype : *fun [ObjGtkWidget u0 I I [I I] [S I]] u2*
167
table
168
|1. *widget*|ObjGtkWidget|a widget| |
169
|2. *userparam*|u0|a user parameter, at your convenience| |
170
|3. *direction*|I|the direction|SCOL_GTK_EVENT_SCROLL_UP|
171
| | | |SCOL_GTK_EVENT_SCROLL_DOWN|
172
| | | |SCOL_GTK_EVENT_SCROLL_LEFT|
173
| | | |SCOL_GTK_EVENT_SCROLL_RIGHT|
174
| | | |SCOL_GTK_EVENT_SCROLL_UNKNOWN|
175
|4. *mask*|I|the mask of the modifier keys|SCOL_GTK_EVENT_KEY_SHIFT|
176
| | | |SCOL_GTK_EVENT_KEY_CONTROL,|
177
| | | |SCOL_GTK_EVENT_KEY_ALT,|
178
| | | |SCOL_GTK_EVENT_KEY_CAPS (can not work : system, window manager, ...)|
179
| | | |SCOL_GTK_EVENT_KEY_HYPER (can not work : system, window manager, ...)|
180
| | | |SCOL_GTK_EVENT_KEY_SUPER (can not work : system, window manager, ...)|
181
| | | |SCOL_GTK_EVENT_KEY_OTHER (or nothing)|
182
|5. *coord*|[I I]|x and y coordinates| |
183
|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|
184
| | | |SCOL_DEVICE_MOUSE,|
185
| | | |SCOL_DEVICE_PEN,|
186
| | | |SCOL_DEVICE_ERASER,|
187
| | | |SCOL_DEVICE_CURSOR,|
188
| | | |SCOL_DEVICE_KEYBOARD,|
189
| | | |SCOL_DEVICE_UNKNOWN|
190
191
192 13 iri
193 19 iri
h1. Window only
194 18 iri
195
h2. SCOL_GTK_WINDOW_STATE
196
197
when the state of a window changes.
198
199
Prototype : *fun [ObjGtkWidget u0 I] u2*
200
201
table
202
|1. *widget*|ObjGtkWidget|a widget|Warning : widget *must* be a window (GtkWindow, see "_gtkWidgetTypeName":http://trac.scolring.org/projects/lib2dgtk/wiki/Widgets)|
203
|2. *userparam*|u0|a user parameter, at your convenience| |
204
|3. *state*|I|what flags have changed ?|SCOL_WINDOW_NOTSHOWN the window is not shown|
205
| | | |SCOL_WINDOW_ICONIFIED the window is minimized|
206
| | | |SCOL_WINDOW_MAXIMIZED the window is maximized|
207
| | | |SCOL_WINDOW_STICKY the window is sticky|
208
| | | |SCOL_WINDOW_FULLSCREEN the window is maximized without decorations|
209
| | | |SCOL_WINDOW_ABOVE the window is kept above other windows|
210
| | | |SCOL_WINDOW_BELOW the window is kept below other windows|
211
| | | |SCOL_WINDOW_STATE_UNKNOWN the state is unknown|
212
213
214
215
216 19 iri
h1. Button only
217 14 iri
218 13 iri
h2. SCOL_GTK_BUTTON_CLICKED
219
220
A button has been clicked
221 1 iri
Prototype : *fun [ObjGtkWidget u0] u2*
222 18 iri
Warning : widget *must* be a button (GtkButton, see "_gtkWidgetTypeName":http://trac.scolring.org/projects/lib2dgtk/wiki/Widgets)
223 13 iri
224 12 iri
225 22 iri
h1. Notebook only
226
227
h2. SCOL_GTK_NOTEBOOK_CHANGE
228
229
when the user or a function changes the current tab/page.
230
Prototype : *fun [ObjGtkWidget u0 I] u2*
231
The supplemental argument is the index of the new current tab
232 6 iri
233 23 iri
h1. TextBuffer only
234
235
h2. SCOL_GTK_TEXTBUFFER_CHANGE
236
237
when the content of a text buffer object change.
238
Prototype : *fun [ObjGtkWidget u0] u2*
239
240 1 iri
Return [[Widgets]]