author | Radek Brich <radek.brich@devl.cz> |
Sun, 06 Jan 2013 13:55:02 +0100 | |
changeset 53 | c4263588b716 |
parent 45 | 43b2279b06e1 |
child 73 | 85a282b5e4fc |
permissions | -rw-r--r-- |
45
43b2279b06e1
Clean up Emitter class, simplify event handling. Fix Container.focusnext() method. Add events test (handler auto-registration, order).
Radek Brich <radek.brich@devl.cz>
parents:
38
diff
changeset
|
1 |
Events |
43b2279b06e1
Clean up Emitter class, simplify event handling. Fix Container.focusnext() method. Add events test (handler auto-registration, order).
Radek Brich <radek.brich@devl.cz>
parents:
38
diff
changeset
|
2 |
====== |
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
|
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 |
|
38
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
12 |
Keypress event |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
13 |
-------------- |
36 | 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 |
||
38
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
27 |
Focus |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
28 |
----- |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
29 |
|
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
30 |
Basics: |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
31 |
* Only one node in hierarchy can have focus. |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
32 |
* All parent containers have focus, so they can relay events to focused child. |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
33 |
* Top container has always focus. |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
34 |
|
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
35 |
Each container maintains its focus child and allows to cycle focus between children (See Container.focus_next). Focus cycling works throughout |
36 | 36 |
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. |
37 |
||
38 |
When focus changes, two events are generated: focus on new widget, unfocus on previous one. |
|
39 |
Mousedown causes focus change when allowed (Widget.allow_focus). |
|
40 |
||
38
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
41 |
* Use grab_focus() on widget to make it receive keyboard events. This will clean old focus and set focus to this child. |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
42 |
* Global shortcuts can be handled in keypress event from top widget. All keyboard events go through there. |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
43 |
* Tab key changes focus to next widget. Shift-tab changes back to previous widget (FIXME: not implemented). |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
44 |
* Hide on focused widget causes focus change like if tab key was pressed. |
36 | 45 |
|
38
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
46 |
See Container.trap_focus, Widget.can_focus(), Widget.has_focus(), Widget.set_focus() 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
|
47 |
|
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
|
48 |
|
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
|
49 |
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
|
50 |
----------------------- |
36 | 51 |
|
52 |
Normal events are propagated in top down order, to all children in each level, in order of child addition. |
|
53 |
Some events choose one or more of children for event propagation. In case of mouse events, child is chosen based on mouse cursor position. |
|
54 |