author | Radek Brich <radek.brich@devl.cz> |
Mon, 17 Dec 2012 21:07:59 +0100 | |
changeset 37 | 54dd866b8951 |
parent 36 | caf927c3f10b |
child 38 | c6e170452c7f |
permissions | -rw-r--r-- |
9
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1 |
Event handling |
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
2 |
============== |
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
3 |
|
36 | 4 |
Draw event |
5 |
---------- |
|
6 |
||
7 |
Draw event is generating for all widgets in top down order - top window is drawn first, then its children etc. |
|
8 |
See TopWindow.draw(), Container.draw(), Widget.draw() - these methods control the draw event propagation. |
|
9 |
Normal widgets should implement only on_draw() method, which is called from draw(). |
|
10 |
||
9
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
11 |
|
36 | 12 |
Keypress event, focus |
13 |
--------------------- |
|
14 |
||
15 |
Keyboard events go in top down order, from top window to focused widget in each level. When implementing on_keypress method, |
|
16 |
add super().on_keypress(). Anything before that will be executed in top down walk, anything after in bottom up. Return True if you want to stop |
|
17 |
the walk. |
|
18 |
||
19 |
:: |
|
9
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
20 |
|
36 | 21 |
before after |
22 |
1 7 top window |
|
23 |
2 6 window |
|
24 |
3 5 container |
|
25 |
4 4 edit box |
|
26 |
||
27 |
Each container maintains its focus child and allows to cycle focus between children (See Container.focusnext). Focus cycling works throughout |
|
28 |
container levels - if focus was on last child and would go to the first, 'tab' key is not handled thus allowing parent level to cycle focus. |
|
29 |
||
30 |
When focus changes, two events are generated: focus on new widget, unfocus on previous one. |
|
31 |
Mousedown causes focus change when allowed (Widget.allow_focus). |
|
32 |
||
33 |
* tab key - change focus to next widget |
|
34 |
* shift-tab - previous widget (FIXME: not implemented) |
|
35 |
||
36 |
Hide on focused widget causes focus change like if tab key was pressed. |
|
37 |
||
38 |
See Container.trapfocus, Widget.canfocus(), Widget.hasfocus(), Widget.setfocus() for more information. |
|
9
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
39 |
|
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
40 |
|
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
41 |
Other event propagation |
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
42 |
----------------------- |
36 | 43 |
|
44 |
Normal events are propagated in top down order, to all children in each level, in order of child addition. |
|
45 |
Some events choose one or more of children for event propagation. In case of mouse events, child is chosen based on mouse cursor position. |
|
46 |