Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 133 lines (117 sloc) 4.855 kb
ceb6a35 snapshot save
megaannum authored
1 # Viewer
2
3 A Viewer is a Mono Glyph. Its primary purpose is to handle keyboard and
4 mouse events. It does this in its 'run()' method.
5
6 At the top of the Viewer 'run()' method its child tree of Glyphs is
7 walked and a list is formed of Glyphs that can accept focus and the
8 first Glyph in that list is the Glyph that currently has focus.
9
10 Also, the Viewer is pushed onto the Forms' Viewer Stack. Some events
11 are handled differently if the Viewer is the only Viewer in the
9e930f0 seventh tutorial snapshot save
megaannum authored
12 Stack or not. Also, when a <LeftMouse> click occurs outside of the
ceb6a35 snapshot save
megaannum authored
13 current Viewer, but still within the boundaries of the Form, then
14 Viewers are popped off the Viewer Stack until a Viewer is found
15 that contains the line/column position of the mouse click and it
16 becomes the active Viewer.
17
18 The Viewer Event Loop reads events from the global event Input Queue.
19 The Function to get the next event is shown below:
20
21 function! forms#GetInput()
22 return empty(s:inputlist) ? getchar() : remove(s:inputlist, 0)
23 endfunction
24
25 If the 's:inputlist' is empty, then the Viewer waits until a character
26 is ready to be returned by the Vim Function 'getchar()'. If the
27 's:inputlist' is not empty, the first event is remove from it and
28 returned.
29
30 The Viewer Event Loop determines what to do with the Event based
31 upon what it is and its value. An event could be a String/Number
32 return by 'getchar()' or it could be a Dictionary Event which,
33 at minimum, has a 'type' attribute. For example, the 'Cancel' Event
34 has a 'type' attribute with value 'Cancel' and the 'Submit' Event
35 has a 'type' of 'Submit'.
36
37 The following is a list of the Event types:
38
39 * Exit
40 - Action: exit current viewer, if top viewer, no results data
41 - Also used as top-of-stack return value for Viewer
9e930f0 seventh tutorial snapshot save
megaannum authored
42 - The character <Esc> is mapped to Exit
ceb6a35 snapshot save
megaannum authored
43 * Cancel
44 - Action: exit form, no results data
45 - Also used as top-of-stack return value for Viewer
46 * Command
47 - Action: exit form, no result data, and execute command
48 * Context
49 - Action: generate context help Form with application specific help/info
50 and developer tools
51 - Data: optional Point [line, column]
9e930f0 seventh tutorial snapshot save
megaannum authored
52 - The character <RightMouse> is mapped to Context
ceb6a35 snapshot save
megaannum authored
53 * Drag
54 - Action: none
9e930f0 seventh tutorial snapshot save
megaannum authored
55 - The character <LeftDrag> is mapped to Drag
ceb6a35 snapshot save
megaannum authored
56 * Release
57 - Action: none
9e930f0 seventh tutorial snapshot save
megaannum authored
58 - The character <LeftRelease> is mapped to Release
ceb6a35 snapshot save
megaannum authored
59 * NewFocus
60 - Action: find new focus based upon mouse coordinates
9e930f0 seventh tutorial snapshot save
megaannum authored
61 - The character <LeftMouse> is mapped to NewFocus
ceb6a35 snapshot save
megaannum authored
62 - Also, if a Viewer is the target of a Select Event, it is mapped
63 to NewFocus
64 * NextFocus
65 - Action: go to next focus
9e930f0 seventh tutorial snapshot save
megaannum authored
66 - The characters <Tab>, <C-n> and <Down> is mapped to NextFocus
67 - The mouse <ScrollWheelDown> event is mapped to NextFocus
ceb6a35 snapshot save
megaannum authored
68 * PrevFocus
69 - Action: go to previous focus
9e930f0 seventh tutorial snapshot save
megaannum authored
70 - The characters <S-Tab>, <C-p> and <Up> is mapped to PrevFocus
ceb6a35 snapshot save
megaannum authored
71 (Note: could not test S-Tab on my system.)
9e930f0 seventh tutorial snapshot save
megaannum authored
72 - The mouse <ScrollWheelUp> event is mapped to PrevFocus
ceb6a35 snapshot save
megaannum authored
73 * FirstFocus
74 - Action: go to first focus glyph
9e930f0 seventh tutorial snapshot save
megaannum authored
75 - The character <Home> is mapped to FirstFocus
ceb6a35 snapshot save
megaannum authored
76 * LastFocus
77 - Action: go to last focus glyph
9e930f0 seventh tutorial snapshot save
megaannum authored
78 - The character <End> is mapped to LastFocus
ceb6a35 snapshot save
megaannum authored
79 * ReDraw
80 - Action: redraw Form in window
81 * ReDrawAll
82 - Action: redraw complete form
83 * ReFocus
84 - Action: View creates a list of glyphs that can get focus
85 this event tells viewer to regenerate that list
86 * ReSize
87 - Action: Form does a requestedSize call on its body because a child has
88 changed size or gone from invisible to visible
89 * Select
90 - Action: change focus and possibly glyph specific sub-selection
91 - Data: Point [line, column]
92 * SelectDouble
93 - Action: a left mouse double click occured
94 - Data: Point [line, column]
9e930f0 seventh tutorial snapshot save
megaannum authored
95 - The mouse <2-LeftMouse> event is mapped to SelectDouble
ceb6a35 snapshot save
megaannum authored
96 * Sleep
97 - Action: Viewer Event handling sleeps for given time.
98 - Data: time: Number (e.g., 10) or String (Number+'m' e.g., 200m)
99 - Used for visual testing
100 * Submit
101 - Action: exit form with result data
102 - Data: results from form
103 - Also used as top-of-stack return value for Viewer
104
105 Special Key Types
106
107 * Down
108 - Produced by down key and viewer maps ScrollWheelDown to Down
109 * Up
110 - Produced by up key and viewer maps ScrollWheelUp to Up
111 * Left S-Left C-Left
112 * Right S-Right C-Right
113 * ScrollWheelDown S-ScrollWheelDown C-ScrollWheelDown
114 * ScrollWheelUp S-ScrollWheelUp C-ScrollWheelUp
115 * Space
116 - Mapped to Select
117 * CR
118 - Mapped to Select
119 * Del
120 - Generally, erase character in editor
121 * BS
122 - Generally, move over character in editor
123
124
125 When the Event Loop exits, the Viewer is popped of the Viewer Stack
126 and the 'run()' method returns.
127
128
129 It is possible to have a Viewer none of whose descendant Glyphs can
130 accept focus. In that case, its is a display-only Viewer and the
9e930f0 seventh tutorial snapshot save
megaannum authored
131 only thing a user can do is enter <Esc> to exit the Viewer or
132 enter <Ctrl-H> which will provide context-sensitive-help.
Something went wrong with that request. Please try again.