45void MouseInactivityDetector::timerCallback()
50void MouseInactivityDetector::wakeUp (
const MouseEvent& e,
bool alwaysWake)
52 auto newPos = e.getEventRelativeTo (&targetComp).getPosition();
54 if ((! isActive) && (
alwaysWake || e.source.isTouch() ||
newPos.getDistanceFrom (lastMousePos) > toleranceDistance))
57 if (lastMousePos !=
newPos)
64void MouseInactivityDetector::setActive (
bool b)
71 listenerList.call ([] (Listener&
l) {
l.mouseBecameActive(); });
73 listenerList.call ([] (Listener&
l) {
l.mouseBecameInactive(); });
The base class for all JUCE user-interface objects.
void addMouseListener(MouseListener *newListener, bool wantsEventsForAllNestedChildComponents)
Registers a listener to be told when mouse events occur in this component.
void removeMouseListener(MouseListener *listenerToRemove)
Deregisters a mouse listener.
Classes should implement this to receive callbacks from a MouseInactivityDetector when the mouse beco...
MouseInactivityDetector(Component &target)
Creates an inactivity watcher, attached to the given component.
void addListener(Listener *listener)
Registers a listener.
void setMouseMoveTolerance(int pixelsNeededToTrigger) noexcept
Sets the number of pixels by which the cursor is allowed to drift before it is considered to be activ...
~MouseInactivityDetector() override
Destructor.
void removeListener(Listener *listener)
Removes a previously-registered listener.
void setDelay(int newDelayMilliseconds) noexcept
Sets the time for which the mouse must be still before the callback is triggered.
void startTimer(int intervalInMilliseconds) noexcept
Starts the timer and sets the length of interval required.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...