LMMS
Loading...
Searching...
No Matches
juce::MouseInactivityDetector Class Reference

#include <juce_MouseInactivityDetector.h>

Inheritance diagram for juce::MouseInactivityDetector:
juce::Timer juce::MouseListener

Classes

class  Listener

Public Member Functions

 MouseInactivityDetector (Component &target)
 ~MouseInactivityDetector () override
void setDelay (int newDelayMilliseconds) noexcept
void setMouseMoveTolerance (int pixelsNeededToTrigger) noexcept
void addListener (Listener *listener)
void removeListener (Listener *listener)

Private Member Functions

void timerCallback () override
void wakeUp (const MouseEvent &, bool alwaysWake)
void setActive (bool)
void mouseMove (const MouseEvent &e) override
void mouseEnter (const MouseEvent &e) override
void mouseExit (const MouseEvent &e) override
void mouseDown (const MouseEvent &e) override
void mouseDrag (const MouseEvent &e) override
void mouseUp (const MouseEvent &e) override
void mouseWheelMove (const MouseEvent &e, const MouseWheelDetails &) override
Private Member Functions inherited from juce::Timer
virtual ~Timer ()
void startTimer (int intervalInMilliseconds) noexcept
void startTimerHz (int timerFrequencyHz) noexcept
void stopTimer () noexcept
bool isTimerRunning () const noexcept
int getTimerInterval () const noexcept
 Timer () noexcept
 Timer (const Timer &) noexcept
Private Member Functions inherited from juce::MouseListener
virtual ~MouseListener ()=default
virtual void mouseDoubleClick (const MouseEvent &event)
virtual void mouseMagnify (const MouseEvent &event, float scaleFactor)

Private Attributes

ComponenttargetComp
ListenerList< ListenerlistenerList
Point< intlastMousePos
int delayMs = 1500
int toleranceDistance = 15
bool isActive = true

Additional Inherited Members

Static Private Member Functions inherited from juce::Timer
static void JUCE_CALLTYPE callAfterDelay (int milliseconds, std::function< void()> functionToCall)
static void JUCE_CALLTYPE callPendingTimersSynchronously ()

Detailed Description

This object watches for mouse-events happening within a component, and if the mouse remains still for long enough, triggers an event to indicate that it has become inactive.

You'd use this for situations where e.g. you want to hide the mouse-cursor when the user's not actively using the mouse.

After creating an instance of this, use addListener to get callbacks when the activity status changes.

@tags{GUI}

Constructor & Destructor Documentation

◆ MouseInactivityDetector()

juce::MouseInactivityDetector::MouseInactivityDetector ( Component & target)

Creates an inactivity watcher, attached to the given component. The target component must not be deleted while this - it will be monitored for any mouse events in it or its child components.

◆ ~MouseInactivityDetector()

juce::MouseInactivityDetector::~MouseInactivityDetector ( )
override

Destructor.

Member Function Documentation

◆ addListener()

void juce::MouseInactivityDetector::addListener ( Listener * listener)

Registers a listener.

◆ mouseDown()

void juce::MouseInactivityDetector::mouseDown ( const MouseEvent & event)
inlineoverrideprivatevirtual

Called when a mouse button is pressed.

The MouseEvent object passed in contains lots of methods for finding out which button was pressed, as well as which modifier keys (e.g. shift, ctrl) were held down at the time.

Once a button is held down, the mouseDrag method will be called when the mouse moves, until the button is released.

Parameters
Eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseUp, mouseDrag, mouseDoubleClick, contains

Reimplemented from juce::MouseListener.

◆ mouseDrag()

void juce::MouseInactivityDetector::mouseDrag ( const MouseEvent & event)
inlineoverrideprivatevirtual

Called when the mouse is moved while a button is held down.

When a mouse button is pressed inside a component, that component receives mouseDrag callbacks each time the mouse moves, even if the mouse strays outside the component's bounds.

Parameters
Eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseDown, mouseUp, mouseMove, contains, setDragRepeatInterval

Reimplemented from juce::MouseListener.

◆ mouseEnter()

void juce::MouseInactivityDetector::mouseEnter ( const MouseEvent & event)
inlineoverrideprivatevirtual

Called when the mouse first enters a component.

If the mouse button isn't pressed and the mouse moves into a component, this will be called to let the component react to this.

When the mouse button is pressed and held down while being moved in or out of a component, no mouseEnter or mouseExit callbacks are made - only mouseDrag messages are sent to the component that the mouse was originally clicked on, until the button is released.

Parameters
Eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseExit, mouseDrag, mouseMove, contains

Reimplemented from juce::MouseListener.

◆ mouseExit()

void juce::MouseInactivityDetector::mouseExit ( const MouseEvent & event)
inlineoverrideprivatevirtual

Called when the mouse moves out of a component.

This will be called when the mouse moves off the edge of this component.

If the mouse button was pressed, and it was then dragged off the edge of the component and released, then this callback will happen when the button is released, after the mouseUp callback.

Parameters
Eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseEnter, mouseDrag, mouseMove, contains

Reimplemented from juce::MouseListener.

◆ mouseMove()

void juce::MouseInactivityDetector::mouseMove ( const MouseEvent & event)
inlineoverrideprivatevirtual

Called when the mouse moves inside a component.

If the mouse button isn't pressed and the mouse moves over a component, this will be called to let the component react to this.

A component will always get a mouseEnter callback before a mouseMove.

Parameters
Eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseEnter, mouseExit, mouseDrag, contains

Reimplemented from juce::MouseListener.

◆ mouseUp()

void juce::MouseInactivityDetector::mouseUp ( const MouseEvent & event)
inlineoverrideprivatevirtual

Called when a mouse button is released.

A mouseUp callback is sent to the component in which a button was pressed even if the mouse is actually over a different component when the button is released.

The MouseEvent object passed in contains lots of methods for finding out which buttons were down just before they were released.

Parameters
Eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseDown, mouseDrag, mouseDoubleClick, contains

Reimplemented from juce::MouseListener.

◆ mouseWheelMove()

void juce::MouseInactivityDetector::mouseWheelMove ( const MouseEvent & event,
const MouseWheelDetails & wheel )
inlineoverrideprivatevirtual

Called when the mouse-wheel is moved.

This callback is sent to the component that the mouse is over when the wheel is moved.

If not overridden, a component will forward this message to its parent, so that parent components can collect mouse-wheel messages that happen to child components which aren't interested in them.

Parameters
Eventdetails about the mouse event
wheeldetails about the wheel movement

Reimplemented from juce::MouseListener.

◆ removeListener()

void juce::MouseInactivityDetector::removeListener ( Listener * listener)

Removes a previously-registered listener.

◆ setActive()

void juce::MouseInactivityDetector::setActive ( bool b)
private

◆ setDelay()

void juce::MouseInactivityDetector::setDelay ( int newDelayMilliseconds)
noexcept

Sets the time for which the mouse must be still before the callback is triggered.

◆ setMouseMoveTolerance()

void juce::MouseInactivityDetector::setMouseMoveTolerance ( int pixelsNeededToTrigger)
noexcept

Sets the number of pixels by which the cursor is allowed to drift before it is considered to be actively moved.

◆ timerCallback()

void juce::MouseInactivityDetector::timerCallback ( )
overrideprivatevirtual

The user-defined callback routine that actually gets called periodically.

It's perfectly ok to call startTimer() or stopTimer() from within this callback to change the subsequent intervals.

Implements juce::Timer.

◆ wakeUp()

void juce::MouseInactivityDetector::wakeUp ( const MouseEvent & e,
bool alwaysWake )
private

Member Data Documentation

◆ delayMs

int juce::MouseInactivityDetector::delayMs = 1500
private

◆ isActive

bool juce::MouseInactivityDetector::isActive = true
private

◆ lastMousePos

Point<int> juce::MouseInactivityDetector::lastMousePos
private

◆ listenerList

ListenerList<Listener> juce::MouseInactivityDetector::listenerList
private

◆ targetComp

Component& juce::MouseInactivityDetector::targetComp
private

◆ toleranceDistance

int juce::MouseInactivityDetector::toleranceDistance = 15
private

The documentation for this class was generated from the following files: