30 return _has_mouse && (_internal_suppress & MouseWatcherRegion::SF_mouse_position) == 0;
40 static LPoint2 bogus_mouse(0.0f, 0.0f);
41 nassertr(_has_mouse, bogus_mouse);
52 nassertr(_has_mouse, 0.0f);
62 nassertr(_has_mouse, 0.0f);
71 set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) {
72 set_frame(LVecBase4(left, right, bottom, top));
129 return _preferred_region;
147 return _inactivity_state != IS_inactive && _current_buttons_down.
get_bit(button.
get_index());
164 _button_down_pattern = pattern;
173 return _button_down_pattern;
182 _button_up_pattern = pattern;
191 return _button_up_pattern;
208 _button_repeat_pattern = pattern;
218 return _button_repeat_pattern;
229 _enter_pattern = pattern;
240 return _enter_pattern;
251 _leave_pattern = pattern;
262 return _leave_pattern;
273 _within_pattern = pattern;
284 return _within_pattern;
295 _without_pattern = pattern;
306 return _without_pattern;
326 return !_geometry.is_null();
393 _display_region = dr;
394 _button_down_display_region =
nullptr;
403 _display_region =
nullptr;
404 _button_down_display_region =
nullptr;
413 return _display_region;
424 return (_display_region !=
nullptr);
439 _has_inactivity_timeout =
true;
440 _inactivity_timeout = timeout;
449 return _has_inactivity_timeout;
458 nassertr(_has_inactivity_timeout, 0.0);
459 return _inactivity_timeout;
468 _has_inactivity_timeout =
false;
469 _inactivity_timeout = 0.0;
479 _inactivity_timeout_event = event;
488 return _inactivity_timeout_event;
495 INLINE
void MouseWatcher::
498 throw_event_pattern(_within_pattern, region, ButtonHandle::none());
499 if (_enter_multiple) {
500 enter_region(region, param);
508 INLINE
void MouseWatcher::
510 if (_enter_multiple) {
511 exit_region(region, param);
514 throw_event_pattern(_without_pattern, region, ButtonHandle::none());
536 get_trail_log()
const {
545 INLINE
size_t MouseWatcher::
546 num_trail_recent()
const {
547 return _num_trail_recent;
void set_modifier_buttons(const ModifierButtons &mods)
Sets the buttons that should be monitored as modifier buttons for generating events to the MouseWatch...
MouseWatcherRegion * get_over_region() const
Returns the smallest region the mouse is currently over, or NULL if it is over no region.
void set_leave_pattern(const std::string &pattern)
Sets the pattern string that indicates how the event names are generated when the mouse leaves a regi...
A basic node of the scene graph or data graph.
void set_button_repeat_pattern(const std::string &pattern)
Sets the pattern string that indicates how the event names are generated when a button is continuousl...
virtual void without_region(const MouseWatcherParameter ¶m)
This is a callback hook function, called whenever the mouse moves completely outside the boundaries o...
const std::string & get_within_pattern() const
Returns the string that indicates how event names are generated when the mouse wanders over a region.
DisplayRegion * get_display_region() const
Returns the display region the MouseWatcher is constrained to by set_display_region(),...
double get_inactivity_timeout() const
Returns the inactivity timeout that has been set.
A class to monitor events from the C++ side of things.
bool get_bit(int index) const
Returns true if the nth bit is set, false if it is cleared.
void set_button_up_pattern(const std::string &pattern)
Sets the pattern string that indicates how the event names are generated when a button is released.
bool has_inactivity_timeout() const
Returns true if an inactivity timeout has been set, false otherwise.
void set_inactivity_timeout(double timeout)
Sets an inactivity timeout on the mouse activity.
EventHandler * get_extra_handler() const
As an optimization for the C++ Gui, an extra handler can be registered with a mouseWatcher so that ev...
const LPoint2 & get_mouse() const
It is only valid to call this if has_mouse() returns true.
PandaNode * get_geometry() const
Returns the node that has been set as the software mouse pointer, or NULL if no node has been set.
void set_enter_pattern(const std::string &pattern)
Sets the pattern string that indicates how the event names are generated when the mouse enters a regi...
void set_button_down_pattern(const std::string &pattern)
Sets the pattern string that indicates how the event names are generated when a button is depressed.
Records a set of pointer events that happened recently.
const std::string & get_leave_pattern() const
Returns the string that indicates how event names are generated when the mouse leaves a region.
void clear_inactivity_timeout()
Removes the inactivity timeout and restores the MouseWatcher to its default behavior of allowing a ke...
void set_inactivity_timeout_event(const std::string &event)
Specifies the event string that will be generated when the inactivity timeout counter expires.
const std::string & get_button_down_pattern() const
Returns the string that indicates how event names are generated when a button is depressed.
const std::string & get_without_pattern() const
Returns the string that indicates how event names are generated when the mouse wanders out of a regio...
virtual void within_region(const MouseWatcherParameter ¶m)
This is a callback hook function, called whenever the mouse moves within the boundaries of the region...
void set_without_pattern(const std::string &pattern)
Sets the pattern string that indicates how the event names are generated when the mouse wanders out o...
bool has_mouse() const
Returns true if the mouse is anywhere within the window, false otherwise.
void set_display_region(DisplayRegion *dr)
Constrains the MouseWatcher to watching the mouse within a particular indicated region of the screen.
bool is_over_region() const
Returns true if the mouse is over any rectangular region, false otherwise.
const std::string & get_inactivity_timeout_event() const
Returns the event string that will be generated when the inactivity timeout counter expires.
This is the class that defines a rectangular region on the screen for the MouseWatcher.
const std::string & get_enter_pattern() const
Returns the string that indicates how event names are generated when the mouse enters a region.
void clear_geometry()
Stops the use of the software cursor set up via set_geometry().
bool has_geometry() const
Returns true if a software mouse pointer has been setup via set_geometry(), or false otherwise.
const LVecBase4 & get_frame() const
Returns the frame of the MouseWatcher.
bool is_mouse_open() const
Returns true if the mouse is within the window and not over some particular MouseWatcherRegion that i...
const std::string & get_button_repeat_pattern() const
Returns the string that indicates how event names are names are generated when a button is continuous...
void set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top)
Sets the frame of the MouseWatcher.
void note_activity()
Can be used in conjunction with the inactivity timeout to inform the MouseWatcher that the user has j...
void clear_trail_log()
Clears the mouse trail log.
A rectangular subregion within a window for rendering into.
void set_extra_handler(EventHandler *eh)
As an optimization for the C++ Gui, an extra handler can be registered with a mouseWatcher so that ev...
bool has_display_region() const
Returns true if the MouseWatcher has been constrained to a particular region of the screen via set_di...
ModifierButtons get_modifier_buttons() const
Returns the set of buttons that are being monitored as modifier buttons, as well as their current sta...
This is sent along as a parameter to most events generated for a region to indicate the mouse and but...
PN_stdfloat get_mouse_y() const
It is only valid to call this if has_mouse() returns true.
void set_geometry(PandaNode *node)
Sets the node that will be transformed each frame by the mouse's coordinates.
void set_within_pattern(const std::string &pattern)
Sets the pattern string that indicates how the event names are generated when the mouse wanders over ...
bool is_button_down(ButtonHandle button) const
Returns true if the indicated button is currently being held down, false otherwise.
PN_stdfloat get_mouse_x() const
It is only valid to call this if has_mouse() returns true.
void clear_display_region()
Removes the display region constraint from the MouseWatcher, and restores it to the default behavior ...
const std::string & get_button_up_pattern() const
Returns the string that indicates how event names are generated when a button is released.