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