Panda3D
buttonThrower.I
1 // Filename: buttonThrower.I
2 // Created by: drose (26Dec03)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: ButtonThrower::set_button_down_event
18 // Access: Published
19 // Description: Specifies the generic event that is generated (if
20 // any) each time a key or button is depressed. Unlike
21 // the specific events that are unique to each key, this
22 // same event name is used for *all* button events, and
23 // the name of the button pressed (possibly with
24 // modifier prefixes) will be sent as a parameter.
25 //
26 // If this string is empty, no event is generated. It
27 // is possible to generate both generic events and
28 // specific events for the same button.
29 //
30 // See also set_keystroke_event().
31 ////////////////////////////////////////////////////////////////////
32 INLINE void ButtonThrower::
33 set_button_down_event(const string &button_down_event) {
34  _button_down_event = button_down_event;
35 }
36 
37 ////////////////////////////////////////////////////////////////////
38 // Function: ButtonThrower::get_button_down_event
39 // Access: Published
40 // Description: Returns the button_down_event that has been set on
41 // this ButtonThrower. See set_button_down_event().
42 ////////////////////////////////////////////////////////////////////
43 INLINE const string &ButtonThrower::
45  return _button_down_event;
46 }
47 
48 ////////////////////////////////////////////////////////////////////
49 // Function: ButtonThrower::set_button_up_event
50 // Access: Published
51 // Description: Specifies the generic event that is generated (if
52 // any) each time a key or button is released. See
53 // set_button_down_event().
54 ////////////////////////////////////////////////////////////////////
55 INLINE void ButtonThrower::
56 set_button_up_event(const string &button_up_event) {
57  _button_up_event = button_up_event;
58 }
59 
60 ////////////////////////////////////////////////////////////////////
61 // Function: ButtonThrower::get_button_up_event
62 // Access: Published
63 // Description: Returns the button_up_event that has been set on
64 // this ButtonThrower. See set_button_up_event().
65 ////////////////////////////////////////////////////////////////////
66 INLINE const string &ButtonThrower::
68  return _button_up_event;
69 }
70 
71 ////////////////////////////////////////////////////////////////////
72 // Function: ButtonThrower::set_button_repeat_event
73 // Access: Published
74 // Description: Specifies the generic event that is generated (if
75 // any) repeatedly while a key or button is held down.
76 // Unlike the specific events that are unique to each
77 // key, this same event name is used for *all* button
78 // events, and the name of the button pressed (possibly
79 // with modifier prefixes) will be sent as a parameter.
80 //
81 // If this string is empty, no event is generated. It
82 // is possible to generate both generic events and
83 // specific events for the same button.
84 //
85 // See also set_keystroke_event().
86 ////////////////////////////////////////////////////////////////////
87 INLINE void ButtonThrower::
88 set_button_repeat_event(const string &button_repeat_event) {
89  _button_repeat_event = button_repeat_event;
90 }
91 
92 ////////////////////////////////////////////////////////////////////
93 // Function: ButtonThrower::get_button_repeat_event
94 // Access: Published
95 // Description: Returns the button_repeat_event that has been set on
96 // this ButtonThrower. See set_button_repeat_event().
97 ////////////////////////////////////////////////////////////////////
98 INLINE const string &ButtonThrower::
100  return _button_repeat_event;
101 }
102 
103 ////////////////////////////////////////////////////////////////////
104 // Function: ButtonThrower::set_keystroke_event
105 // Access: Published
106 // Description: Specifies the event that is generated (if any) for
107 // each keystroke that is received. A keystroke is
108 // different than a button event: it represents the
109 // semantic meaning of the sequence of keys that have
110 // been pressed. For instance, pressing shift and 4
111 // together will generate the button event "shift-4",
112 // but it will generate the keystroke "$".
113 //
114 // If a key is held down, keyrepeat will cause the same
115 // keystroke event to be generated repeatedly. This is
116 // different from the corresponding down event, which
117 // will only be generated once, followed by a number of
118 // button repeat events.
119 //
120 // This event is generated with a single wstring
121 // parameter, which is a one-character string that
122 // contains the keystroke generated. If this event
123 // string is empty, no event is generated.
124 //
125 // See also set_button_down_event().
126 ////////////////////////////////////////////////////////////////////
127 INLINE void ButtonThrower::
128 set_keystroke_event(const string &keystroke_event) {
129  _keystroke_event = keystroke_event;
130 }
131 
132 ////////////////////////////////////////////////////////////////////
133 // Function: ButtonThrower::get_keystroke_event
134 // Access: Published
135 // Description: Returns the keystroke_event that has been set on this
136 // ButtonThrower. See set_keystroke_event().
137 ////////////////////////////////////////////////////////////////////
138 INLINE const string &ButtonThrower::
140  return _keystroke_event;
141 }
142 
143 ////////////////////////////////////////////////////////////////////
144 // Function: ButtonThrower::set_candidate_event
145 // Access: Published
146 // Description: Specifies the event that is generated (if any) for
147 // each IME candidate string event received. Events of
148 // this nature are received only when the user is
149 // entering data using a Microsoft Input Method Editor,
150 // typically used for Asian languages such as Japanese
151 // or Korean.
152 //
153 // If you are designing a typing user interface, you
154 // should track this event to support the use of the
155 // IME. In response to this event, you should display
156 // the candidate string in the entry box, with the
157 // appropriate sections highlighted, so the user can
158 // scroll through the available choices.
159 //
160 // This event is generated with four parameters, in
161 // order: the candidate string, the character at which
162 // to start the highlight, the character at which to end
163 // the highlight, and the current cursor position.
164 ////////////////////////////////////////////////////////////////////
165 INLINE void ButtonThrower::
166 set_candidate_event(const string &candidate_event) {
167  _candidate_event = candidate_event;
168 }
169 
170 ////////////////////////////////////////////////////////////////////
171 // Function: ButtonThrower::get_candidate_event
172 // Access: Published
173 // Description: Returns the candidate_event that has been set on this
174 // ButtonThrower. See set_candidate_event().
175 ////////////////////////////////////////////////////////////////////
176 INLINE const string &ButtonThrower::
178  return _candidate_event;
179 }
180 
181 ////////////////////////////////////////////////////////////////////
182 // Function: ButtonThrower::set_move_event
183 // Access: Published
184 // Description: Specifies the event that is generated (if any) each
185 // time the mouse is moved within the window.
186 ////////////////////////////////////////////////////////////////////
187 INLINE void ButtonThrower::
188 set_move_event(const string &move_event) {
189  _move_event = move_event;
190 }
191 
192 ////////////////////////////////////////////////////////////////////
193 // Function: ButtonThrower::get_move_event
194 // Access: Published
195 // Description: Returns the move_event that has been set on this
196 // ButtonThrower. See set_move_event().
197 ////////////////////////////////////////////////////////////////////
198 INLINE const string &ButtonThrower::
199 get_move_event() const {
200  return _move_event;
201 }
202 
203 ////////////////////////////////////////////////////////////////////
204 // Function: ButtonThrower::set_raw_button_down_event
205 // Access: Published
206 // Description: Like set_button_down_event, but uses the raw,
207 // untransformed scan key from the operating system.
208 // This uses buttons that are independent of the
209 // user's selected keyboard layout.
210 ////////////////////////////////////////////////////////////////////
211 INLINE void ButtonThrower::
212 set_raw_button_down_event(const string &raw_button_down_event) {
213  _raw_button_down_event = raw_button_down_event;
214 }
215 
216 ////////////////////////////////////////////////////////////////////
217 // Function: ButtonThrower::get_raw_button_down_event
218 // Access: Published
219 // Description: Returns the raw_button_down_event that has been set on
220 // this ButtonThrower. See set_raw_button_down_event().
221 ////////////////////////////////////////////////////////////////////
222 INLINE const string &ButtonThrower::
224  return _raw_button_down_event;
225 }
226 
227 ////////////////////////////////////////////////////////////////////
228 // Function: ButtonThrower::set_raw_button_up_event
229 // Access: Published
230 // Description: Specifies the generic event that is generated (if
231 // any) each time a key or button is released. See
232 // set_raw_button_down_event().
233 ////////////////////////////////////////////////////////////////////
234 INLINE void ButtonThrower::
235 set_raw_button_up_event(const string &raw_button_up_event) {
236  _raw_button_up_event = raw_button_up_event;
237 }
238 
239 ////////////////////////////////////////////////////////////////////
240 // Function: ButtonThrower::get_raw_button_up_event
241 // Access: Published
242 // Description: Returns the raw_button_up_event that has been set on
243 // this ButtonThrower. See set_raw_button_up_event().
244 ////////////////////////////////////////////////////////////////////
245 INLINE const string &ButtonThrower::
247  return _raw_button_up_event;
248 }
249 
250 ////////////////////////////////////////////////////////////////////
251 // Function: ButtonThrower::set_prefix
252 // Access: Published
253 // Description: Sets the prefix which is prepended to all specific
254 // event names (that is, event names generated from the
255 // button name itself, as opposed to the generic event
256 // names like set_button_down_event) thrown by this
257 // object.
258 ////////////////////////////////////////////////////////////////////
259 INLINE void ButtonThrower::
260 set_prefix(const string &prefix) {
261  _prefix = prefix;
262 }
263 
264 ////////////////////////////////////////////////////////////////////
265 // Function: ButtonThrower::get_prefix
266 // Access: Published
267 // Description: Returns the prefix that has been set on this
268 // ButtonThrower. See set_prefix().
269 ////////////////////////////////////////////////////////////////////
270 INLINE const string &ButtonThrower::
271 get_prefix() const {
272  return _prefix;
273 }
274 
275 ////////////////////////////////////////////////////////////////////
276 // Function: ButtonThrower::set_specific_flag
277 // Access: Published
278 // Description: Sets the flag that indicates whether specific events
279 // (events prefixed by set_prefix, and based on the
280 // event name) should be generated at all. This is true
281 // by default, but may be disabled if you are only
282 // interested in the generic events (for instance,
283 // events like set_button_down_event).
284 ////////////////////////////////////////////////////////////////////
285 INLINE void ButtonThrower::
286 set_specific_flag(bool specific_flag) {
287  _specific_flag = specific_flag;
288 }
289 
290 ////////////////////////////////////////////////////////////////////
291 // Function: ButtonThrower::get_specific_flag
292 // Access: Published
293 // Description: Returns the flag that indicates whether specific
294 // events should be generated. See set_specific_flag().
295 ////////////////////////////////////////////////////////////////////
296 INLINE bool ButtonThrower::
298  return _specific_flag;
299 }
300 
301 ////////////////////////////////////////////////////////////////////
302 // Function: ButtonThrower::set_time_flag
303 // Access: Published
304 // Description: Sets the flag that indicates whether the time of the
305 // button event should be passed as a parameter or not.
306 // When this is true, an additional parameter is
307 // generated on each event (before all the parameters
308 // named by add_parameter) that consists of a single
309 // double value, and reflects the time the button was
310 // pressed or released, as a value from
311 // ClockObject::get_global_clock().
312 ////////////////////////////////////////////////////////////////////
313 INLINE void ButtonThrower::
314 set_time_flag(bool time_flag) {
315  _time_flag = time_flag;
316 }
317 
318 ////////////////////////////////////////////////////////////////////
319 // Function: ButtonThrower::get_time_flag
320 // Access: Published
321 // Description: Returns the flag that indicates whether the time of
322 // the button event should be passed as a parameter.
323 ////////////////////////////////////////////////////////////////////
324 INLINE bool ButtonThrower::
325 get_time_flag() const {
326  return _time_flag;
327 }
328 
329 ////////////////////////////////////////////////////////////////////
330 // Function: ButtonThrower::get_modifier_buttons
331 // Access: Published
332 // Description: Returns the set of ModifierButtons that the
333 // ButtonThrower will consider important enough to
334 // prepend the event name with. Normally, this set will
335 // be empty, and the ButtonThrower will therefore ignore
336 // all ModifierButtons attached to the key events, but
337 // if one or more buttons have been added to this set,
338 // and those modifier buttons are set on the button
339 // event, then the event name will be prepended with the
340 // names of the modifier buttons.
341 ////////////////////////////////////////////////////////////////////
342 INLINE const ModifierButtons &ButtonThrower::
344  return _mods;
345 }
346 
347 ////////////////////////////////////////////////////////////////////
348 // Function: ButtonThrower::set_modifier_buttons
349 // Access: Published
350 // Description: Changes the set of ModifierButtons that the
351 // ButtonThrower will consider important enough to
352 // prepend the event name with. Normally, this set will
353 // be empty, and the ButtonThrower will therefore ignore
354 // all ModifierButtons attached to the key events, but
355 // if one or more buttons have been added to this set,
356 // then the event name will be prepended with the names
357 // of the modifier buttons.
358 //
359 // It is recommended that you change this setting by
360 // first calling get_modifier_buttons(), making
361 // adjustments, and passing the new value to
362 // set_modifier_buttons(). This way the current state
363 // of the modifier buttons will not be lost.
364 ////////////////////////////////////////////////////////////////////
365 INLINE void ButtonThrower::
367  _mods = mods;
368 }
369 
370 ////////////////////////////////////////////////////////////////////
371 // Function: ButtonThrower::set_throw_buttons_active
372 // Access: Published
373 // Description: Sets the flag that indicates whether the
374 // ButtonThrower will only process events for the
375 // explicitly named buttons or not. Normally this is
376 // false, meaning all buttons are processed; set it true
377 // to indicate that only some buttons should be
378 // processed. See add_throw_button().
379 ////////////////////////////////////////////////////////////////////
380 INLINE void ButtonThrower::
382  _throw_buttons_active = flag;
383 }
384 
385 ////////////////////////////////////////////////////////////////////
386 // Function: ButtonThrower::get_throw_buttons_active
387 // Access: Published
388 // Description: Returns the flag that indicates whether the
389 // ButtonThrower will only process events for the
390 // explicitly named buttons or not. See
391 // set_throw_buttons_active().
392 ////////////////////////////////////////////////////////////////////
393 INLINE bool ButtonThrower::
395  return _throw_buttons_active;
396 }
void set_move_event(const string &move_event)
Specifies the event that is generated (if any) each time the mouse is moved within the window...
void set_specific_flag(bool specific_flag)
Sets the flag that indicates whether specific events (events prefixed by set_prefix, and based on the event name) should be generated at all.
bool get_throw_buttons_active() const
Returns the flag that indicates whether the ButtonThrower will only process events for the explicitly...
const string & get_raw_button_up_event() const
Returns the raw_button_up_event that has been set on this ButtonThrower.
This class monitors the state of a number of individual buttons and tracks whether each button is kno...
void set_button_repeat_event(const string &button_repeat_event)
Specifies the generic event that is generated (if any) repeatedly while a key or button is held down...
Definition: buttonThrower.I:88
void set_time_flag(bool time_flag)
Sets the flag that indicates whether the time of the button event should be passed as a parameter or ...
void set_keystroke_event(const string &keystroke_event)
Specifies the event that is generated (if any) for each keystroke that is received.
const string & get_button_repeat_event() const
Returns the button_repeat_event that has been set on this ButtonThrower.
Definition: buttonThrower.I:99
const string & get_prefix() const
Returns the prefix that has been set on this ButtonThrower.
bool get_time_flag() const
Returns the flag that indicates whether the time of the button event should be passed as a parameter...
void set_button_up_event(const string &button_up_event)
Specifies the generic event that is generated (if any) each time a key or button is released...
Definition: buttonThrower.I:56
const string & get_candidate_event() const
Returns the candidate_event that has been set on this ButtonThrower.
const ModifierButtons & get_modifier_buttons() const
Returns the set of ModifierButtons that the ButtonThrower will consider important enough to prepend t...
void set_prefix(const string &prefix)
Sets the prefix which is prepended to all specific event names (that is, event names generated from t...
bool get_specific_flag() const
Returns the flag that indicates whether specific events should be generated.
void set_raw_button_up_event(const string &raw_button_up_event)
Specifies the generic event that is generated (if any) each time a key or button is released...
void set_candidate_event(const string &candidate_event)
Specifies the event that is generated (if any) for each IME candidate string event received...
void set_throw_buttons_active(bool flag)
Sets the flag that indicates whether the ButtonThrower will only process events for the explicitly na...
void set_raw_button_down_event(const string &raw_button_down_event)
Like set_button_down_event, but uses the raw, untransformed scan key from the operating system...
const string & get_keystroke_event() const
Returns the keystroke_event that has been set on this ButtonThrower.
void set_button_down_event(const string &button_down_event)
Specifies the generic event that is generated (if any) each time a key or button is depressed...
Definition: buttonThrower.I:33
const string & get_move_event() const
Returns the move_event that has been set on this ButtonThrower.
void set_modifier_buttons(const ModifierButtons &mods)
Changes the set of ModifierButtons that the ButtonThrower will consider important enough to prepend t...
const string & get_raw_button_down_event() const
Returns the raw_button_down_event that has been set on this ButtonThrower.
const string & get_button_up_event() const
Returns the button_up_event that has been set on this ButtonThrower.
Definition: buttonThrower.I:67
const string & get_button_down_event() const
Returns the button_down_event that has been set on this ButtonThrower.
Definition: buttonThrower.I:44