docs/events.rst
author Radek Brich <radek.brich@devl.cz>
Mon, 17 Dec 2012 00:24:34 +0100
changeset 36 caf927c3f10b
parent 9 7175ed629a76
child 38 c6e170452c7f
permissions -rw-r--r--
Update docs.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
     4
Draw event
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
     5
----------
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
     6
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
     7
Draw event is generating for all widgets in top down order - top window is drawn first, then its children etc.
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
     8
See TopWindow.draw(), Container.draw(), Widget.draw() - these methods control the draw event propagation.
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
     9
Normal widgets should implement only on_draw() method, which is called from draw().
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    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
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    12
Keypress event, focus
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    13
---------------------
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    14
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    15
Keyboard events go in top down order, from top window to focused widget in each level. When implementing on_keypress method,
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    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
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    17
the walk.
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    18
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    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
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    21
  before  after
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    22
  1       7      top window
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    23
  2       6        window
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    24
  3       5          container
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    25
  4       4            edit box
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    26
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    27
Each container maintains its focus child and allows to cycle focus between children (See Container.focusnext). Focus cycling works throughout
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    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.
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    29
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    30
When focus changes, two events are generated: focus on new widget, unfocus on previous one.
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    31
Mousedown causes focus change when allowed (Widget.allow_focus).
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    32
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    33
 * tab key - change focus to next widget
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    34
 * shift-tab - previous widget (FIXME: not implemented)
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    35
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    36
Hide on focused widget causes focus change like if tab key was pressed.
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    37
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    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
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    43
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    44
Normal events are propagated in top down order, to all children in each level, in order of child addition.
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    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.
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 9
diff changeset
    46