JUCE  v5.4.1-191-g0ab5e696f
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::MouseInputSource Class Referencefinal

Represents a linear source of mouse events from a mouse device or individual finger in a multi-touch environment. More...

#include <juce_MouseInputSource.h>

Collaboration diagram for juce::MouseInputSource:

Public Types

enum  InputSourceType {
  mouse,
  touch,
  pen
}
 Possible mouse input sources. More...
 

Public Member Functions

 MouseInputSource (const MouseInputSource &) noexcept
 
 ~MouseInputSource () noexcept
 
bool canDoUnboundedMovement () const noexcept
 Returns true if this mouse can be moved indefinitely in any direction without running out of space. More...
 
bool canHover () const noexcept
 Returns true if this source has an on-screen pointer that can hover over items without clicking them. More...
 
void enableUnboundedMouseMovement (bool isEnabled, bool keepCursorVisibleUntilOffscreen=false) const
 Allows the mouse to move beyond the edges of the screen. More...
 
void forceMouseCursorUpdate ()
 Forces an update of the mouse cursor for whatever component it's currently over. More...
 
ComponentgetComponentUnderMouse () const
 Returns the component that was last known to be under this pointer. More...
 
ModifierKeys getCurrentModifiers () const noexcept
 Returns a set of modifiers that indicate which buttons are currently held down on this device. More...
 
float getCurrentOrientation () const noexcept
 Returns the device's current orientation in radians. More...
 
float getCurrentPressure () const noexcept
 Returns the device's current touch or pen pressure. More...
 
float getCurrentRotation () const noexcept
 Returns the device's current rotation. More...
 
float getCurrentTilt (bool tiltX) const noexcept
 Returns the angle of tilt of the pointer in a range of -1.0 to 1.0 either in the x- or y-axis. More...
 
int getIndex () const noexcept
 Returns this source's index in the global list of possible sources. More...
 
Point< floatgetLastMouseDownPosition () const noexcept
 Returns the screen position at which the last mouse-down occurred. More...
 
Time getLastMouseDownTime () const noexcept
 Returns the time at which the last mouse-down occurred. More...
 
int getNumberOfMultipleClicks () const noexcept
 Returns the number of clicks that should be counted as belonging to the current mouse event. More...
 
Point< floatgetRawScreenPosition () const noexcept
 Returns the last-known screen position of this source without any scaling applied. More...
 
Point< floatgetScreenPosition () const noexcept
 Returns the last-known screen position of this source. More...
 
MouseInputSource::InputSourceType getType () const noexcept
 Returns the type of input source that this object represents. More...
 
bool hasMouseCursor () const noexcept
 Returns true if this input source uses a visible mouse cursor. More...
 
bool hasMouseWheel () const noexcept
 Returns true if this source may have a scroll wheel. More...
 
bool hasMovedSignificantlySincePressed () const noexcept
 Returns true if this input source has been dragged more than a couple of pixels from the place it was pressed. More...
 
void hideCursor ()
 Hides the mouse cursor (if there is one). More...
 
bool isDragging () const noexcept
 Returns true if this device is currently being pressed. More...
 
bool isLongPressOrDrag () const noexcept
 Returns true if this input source represents a long-press or drag interaction i.e. More...
 
bool isMouse () const noexcept
 Returns true if this object represents a normal desk-based mouse device. More...
 
bool isOrientationValid () const noexcept
 Returns true if the current orientation value is meaningful. More...
 
bool isPen () const noexcept
 Returns true if this object represents a pen device. More...
 
bool isPressureValid () const noexcept
 Returns true if the current pressure value is meaningful. More...
 
bool isRotationValid () const noexcept
 Returns true if the current rotation value is meaningful. More...
 
bool isTiltValid (bool tiltX) const noexcept
 Returns true if the current tilt value (either x- or y-axis) is meaningful. More...
 
bool isTouch () const noexcept
 Returns true if this object represents a source of touch events. More...
 
bool isUnboundedMouseMovementEnabled () const
 Returns true if this source is currently in "unbounded" mode. More...
 
bool operator!= (const MouseInputSource &other) const noexcept
 
MouseInputSourceoperator= (const MouseInputSource &) noexcept
 
bool operator== (const MouseInputSource &other) const noexcept
 
void revealCursor ()
 Un-hides the mouse cursor if it was hidden by hideCursor(). More...
 
void setScreenPosition (Point< float > newPosition)
 Attempts to set this mouse pointer's screen position. More...
 
void showMouseCursor (const MouseCursor &cursor)
 Changes the mouse cursor, (if there is one). More...
 
void triggerFakeMove () const
 Tells the device to dispatch a mouse-move or mouse-drag event. More...
 

Static Public Attributes

static const float invalidOrientation
 A default value for orientation, which is used when a device doesn't support it. More...
 
static const float invalidPressure
 A default value for pressure, which is used when a device doesn't support it, or for mouse-moves, mouse-ups, etc. More...
 
static const float invalidRotation
 A default value for rotation, which is used when a device doesn't support it. More...
 
static const float invalidTiltX
 Default values for tilt, which are used when a device doesn't support it. More...
 
static const float invalidTiltY
 

Private Member Functions

 MouseInputSource (MouseInputSourceInternal *) noexcept
 
void handleEvent (ComponentPeer &, Point< float >, int64 time, ModifierKeys, float, float, const PenDetails &)
 
void handleMagnifyGesture (ComponentPeer &, Point< float >, int64 time, float scaleFactor)
 
void handleWheel (ComponentPeer &, Point< float >, int64 time, const MouseWheelDetails &)
 

Static Private Member Functions

static Point< floatgetCurrentRawMousePosition ()
 
static void setRawMousePosition (Point< float >)
 

Private Attributes

MouseInputSourceInternalpimpl
 

Friends

class ComponentPeer
 
class Desktop
 
class MouseInputSourceInternal
 

Detailed Description

Represents a linear source of mouse events from a mouse device or individual finger in a multi-touch environment.

Each MouseEvent object contains a reference to the MouseInputSource that generated it. In an environment with a single mouse for input, all events will come from the same source, but in a multi-touch system, there may be multiple MouseInputSource obects active, each representing a stream of events coming from a particular finger.

Events coming from a single MouseInputSource are always sent in a fixed and predictable order: a mouseMove will never be called without a mouseEnter having been sent beforehand, the only events that can happen between a mouseDown and its corresponding mouseUp are mouseDrags, etc. When there are multiple touches arriving from multiple MouseInputSources, their event streams may arrive in an interleaved order, so you should use the getIndex() method to find out which finger each event came from.

See also
MouseEvent

{GUI}

Member Enumeration Documentation

◆ InputSourceType

Possible mouse input sources.

Enumerator
mouse 
touch 
pen 

Constructor & Destructor Documentation

◆ MouseInputSource() [1/2]

juce::MouseInputSource::MouseInputSource ( const MouseInputSource )
noexcept

◆ ~MouseInputSource()

juce::MouseInputSource::~MouseInputSource ( )
noexcept

◆ MouseInputSource() [2/2]

juce::MouseInputSource::MouseInputSource ( MouseInputSourceInternal )
explicitprivatenoexcept

Member Function Documentation

◆ canDoUnboundedMovement()

bool juce::MouseInputSource::canDoUnboundedMovement ( ) const
noexcept

Returns true if this mouse can be moved indefinitely in any direction without running out of space.

◆ canHover()

bool juce::MouseInputSource::canHover ( ) const
noexcept

Returns true if this source has an on-screen pointer that can hover over items without clicking them.

◆ enableUnboundedMouseMovement()

void juce::MouseInputSource::enableUnboundedMouseMovement ( bool  isEnabled,
bool  keepCursorVisibleUntilOffscreen = false 
) const

Allows the mouse to move beyond the edges of the screen.

Calling this method when the mouse button is currently pressed will remove the cursor from the screen and allow the mouse to (seem to) move beyond the edges of the screen.

This means that the coordinates returned to mouseDrag() will be unbounded, and this can be used for things like custom slider controls or dragging objects around, where movement would be otherwise be limited by the mouse hitting the edges of the screen.

The unbounded mode is automatically turned off when the mouse button is released, or it can be turned off explicitly by calling this method again.

Parameters
isEnabledwhether to turn this mode on or off
keepCursorVisibleUntilOffscreenif set to false, the cursor will immediately be hidden; if true, it will only be hidden when it is moved beyond the edge of the screen

◆ forceMouseCursorUpdate()

void juce::MouseInputSource::forceMouseCursorUpdate ( )

Forces an update of the mouse cursor for whatever component it's currently over.

◆ getComponentUnderMouse()

Component* juce::MouseInputSource::getComponentUnderMouse ( ) const

Returns the component that was last known to be under this pointer.

◆ getCurrentModifiers()

ModifierKeys juce::MouseInputSource::getCurrentModifiers ( ) const
noexcept

Returns a set of modifiers that indicate which buttons are currently held down on this device.

◆ getCurrentOrientation()

float juce::MouseInputSource::getCurrentOrientation ( ) const
noexcept

Returns the device's current orientation in radians.

0 indicates a touch pointer aligned with the x-axis and pointing from left to right; increasing values indicate rotation in the clockwise direction. Only reported by a touch pointer.

◆ getCurrentPressure()

float juce::MouseInputSource::getCurrentPressure ( ) const
noexcept

Returns the device's current touch or pen pressure.

The range is 0 (soft) to 1 (hard). If the input device doesn't provide any pressure data, it may return a negative value here, or 0.0 or 1.0, depending on the platform.

◆ getCurrentRawMousePosition()

static Point<float> juce::MouseInputSource::getCurrentRawMousePosition ( )
staticprivate

◆ getCurrentRotation()

float juce::MouseInputSource::getCurrentRotation ( ) const
noexcept

Returns the device's current rotation.

Indicates the clockwise rotation, or twist, of the pointer in radians. The default is 0. Only reported by a pen pointer.

◆ getCurrentTilt()

float juce::MouseInputSource::getCurrentTilt ( bool  tiltX) const
noexcept

Returns the angle of tilt of the pointer in a range of -1.0 to 1.0 either in the x- or y-axis.

The default is 0. If x-axis, a positive value indicates a tilt to the right and if y-axis, a positive value indicates a tilt toward the user. Only reported by a pen pointer.

◆ getIndex()

int juce::MouseInputSource::getIndex ( ) const
noexcept

Returns this source's index in the global list of possible sources.

If the system only has a single mouse, there will only be a single MouseInputSource with an index of 0.

If the system supports multi-touch input, then the index will represent a finger number, starting from 0. When the first touch event begins, it will have finger number 0, and then if a second touch happens while the first is still down, it will have index 1, etc.

◆ getLastMouseDownPosition()

Point<float> juce::MouseInputSource::getLastMouseDownPosition ( ) const
noexcept

Returns the screen position at which the last mouse-down occurred.

◆ getLastMouseDownTime()

Time juce::MouseInputSource::getLastMouseDownTime ( ) const
noexcept

Returns the time at which the last mouse-down occurred.

◆ getNumberOfMultipleClicks()

int juce::MouseInputSource::getNumberOfMultipleClicks ( ) const
noexcept

Returns the number of clicks that should be counted as belonging to the current mouse event.

So the mouse is currently down and it's the second click of a double-click, this will return 2.

◆ getRawScreenPosition()

Point<float> juce::MouseInputSource::getRawScreenPosition ( ) const
noexcept

Returns the last-known screen position of this source without any scaling applied.

◆ getScreenPosition()

Point<float> juce::MouseInputSource::getScreenPosition ( ) const
noexcept

Returns the last-known screen position of this source.

◆ getType()

MouseInputSource::InputSourceType juce::MouseInputSource::getType ( ) const
noexcept

Returns the type of input source that this object represents.

◆ handleEvent()

void juce::MouseInputSource::handleEvent ( ComponentPeer ,
Point< float ,
int64  time,
ModifierKeys  ,
float  ,
float  ,
const PenDetails  
)
private

◆ handleMagnifyGesture()

void juce::MouseInputSource::handleMagnifyGesture ( ComponentPeer ,
Point< float ,
int64  time,
float  scaleFactor 
)
private

◆ handleWheel()

void juce::MouseInputSource::handleWheel ( ComponentPeer ,
Point< float ,
int64  time,
const MouseWheelDetails  
)
private

◆ hasMouseCursor()

bool juce::MouseInputSource::hasMouseCursor ( ) const
noexcept

Returns true if this input source uses a visible mouse cursor.

◆ hasMouseWheel()

bool juce::MouseInputSource::hasMouseWheel ( ) const
noexcept

Returns true if this source may have a scroll wheel.

◆ hasMovedSignificantlySincePressed()

bool juce::MouseInputSource::hasMovedSignificantlySincePressed ( ) const
noexcept

Returns true if this input source has been dragged more than a couple of pixels from the place it was pressed.

◆ hideCursor()

void juce::MouseInputSource::hideCursor ( )

Hides the mouse cursor (if there is one).

◆ isDragging()

bool juce::MouseInputSource::isDragging ( ) const
noexcept

Returns true if this device is currently being pressed.

◆ isLongPressOrDrag()

bool juce::MouseInputSource::isLongPressOrDrag ( ) const
noexcept

Returns true if this input source represents a long-press or drag interaction i.e.

it has been held down for a significant amount of time or it has been dragged more than a couple of pixels from the place it was pressed.

◆ isMouse()

bool juce::MouseInputSource::isMouse ( ) const
noexcept

Returns true if this object represents a normal desk-based mouse device.

◆ isOrientationValid()

bool juce::MouseInputSource::isOrientationValid ( ) const
noexcept

Returns true if the current orientation value is meaningful.

◆ isPen()

bool juce::MouseInputSource::isPen ( ) const
noexcept

Returns true if this object represents a pen device.

◆ isPressureValid()

bool juce::MouseInputSource::isPressureValid ( ) const
noexcept

Returns true if the current pressure value is meaningful.

◆ isRotationValid()

bool juce::MouseInputSource::isRotationValid ( ) const
noexcept

Returns true if the current rotation value is meaningful.

◆ isTiltValid()

bool juce::MouseInputSource::isTiltValid ( bool  tiltX) const
noexcept

Returns true if the current tilt value (either x- or y-axis) is meaningful.

◆ isTouch()

bool juce::MouseInputSource::isTouch ( ) const
noexcept

Returns true if this object represents a source of touch events.

◆ isUnboundedMouseMovementEnabled()

bool juce::MouseInputSource::isUnboundedMouseMovementEnabled ( ) const

Returns true if this source is currently in "unbounded" mode.

◆ operator!=()

bool juce::MouseInputSource::operator!= ( const MouseInputSource other) const
inlinenoexcept

References pimpl.

◆ operator=()

MouseInputSource& juce::MouseInputSource::operator= ( const MouseInputSource )
noexcept

◆ operator==()

bool juce::MouseInputSource::operator== ( const MouseInputSource other) const
inlinenoexcept

References pimpl.

◆ revealCursor()

void juce::MouseInputSource::revealCursor ( )

Un-hides the mouse cursor if it was hidden by hideCursor().

◆ setRawMousePosition()

static void juce::MouseInputSource::setRawMousePosition ( Point< float )
staticprivate

◆ setScreenPosition()

void juce::MouseInputSource::setScreenPosition ( Point< float newPosition)

Attempts to set this mouse pointer's screen position.

◆ showMouseCursor()

void juce::MouseInputSource::showMouseCursor ( const MouseCursor cursor)

Changes the mouse cursor, (if there is one).

◆ triggerFakeMove()

void juce::MouseInputSource::triggerFakeMove ( ) const

Tells the device to dispatch a mouse-move or mouse-drag event.

This is asynchronous - the event will occur on the message thread.

Friends And Related Function Documentation

◆ ComponentPeer

friend class ComponentPeer
friend

◆ Desktop

friend class Desktop
friend

◆ MouseInputSourceInternal

friend class MouseInputSourceInternal
friend

Member Data Documentation

◆ invalidOrientation

const float juce::MouseInputSource::invalidOrientation
static

A default value for orientation, which is used when a device doesn't support it.

◆ invalidPressure

const float juce::MouseInputSource::invalidPressure
static

A default value for pressure, which is used when a device doesn't support it, or for mouse-moves, mouse-ups, etc.

◆ invalidRotation

const float juce::MouseInputSource::invalidRotation
static

A default value for rotation, which is used when a device doesn't support it.

◆ invalidTiltX

const float juce::MouseInputSource::invalidTiltX
static

Default values for tilt, which are used when a device doesn't support it.

◆ invalidTiltY

const float juce::MouseInputSource::invalidTiltY
static

◆ pimpl

MouseInputSourceInternal* juce::MouseInputSource::pimpl
private

Referenced by operator!=(), and operator==().


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