JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Friends | List of all members
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"

Public Types

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

Public Member Functions

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

Static Public Attributes

static constexpr float defaultPressure
 A default value for pressure, which is used when a device doesn't support it, or for mouse-moves, mouse-ups, etc.
 
static constexpr float defaultOrientation
 A default value for orientation, which is used when a device doesn't support it.
 
static constexpr float defaultRotation
 A default value for rotation, which is used when a device doesn't support it.
 
static constexpr float defaultTiltX
 Default values for tilt, which are used when a device doesn't support it.
 
static constexpr float defaultTiltY
 
static const float invalidPressure
 A default value for pressure, which is used when a device doesn't support it.
 
static const float invalidOrientation
 A default value for orientation, which is used when a device doesn't support it.
 
static const float invalidRotation
 A default value for rotation, which is used when a device doesn't support it.
 
static const float invalidTiltX
 Default values for tilt, which are used when a device doesn't support it.
 
static const float invalidTiltY
 
static const Point< floatoffscreenMousePos
 An offscreen mouse position used when triggering mouse exits where we don't want to move the cursor over an existing component.
 

Friends

class ComponentPeer
 
class Desktop
 
class detail::MouseInputSourceList
 
class detail::MouseInputSourceImpl
 

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 objects 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

@tags{GUI}

Definition at line 51 of file juce_MouseInputSource.h.

Member Enumeration Documentation

◆ InputSourceType

Possible mouse input sources.

Definition at line 55 of file juce_MouseInputSource.h.

Constructor & Destructor Documentation

◆ MouseInputSource()

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

Definition at line 31 of file juce_MouseInputSource.cpp.

◆ ~MouseInputSource()

juce::MouseInputSource::~MouseInputSource ( )
noexcept

Definition at line 32 of file juce_MouseInputSource.cpp.

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.

Definition at line 66 of file juce_MouseInputSource.cpp.

◆ 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.

Definition at line 44 of file juce_MouseInputSource.cpp.

◆ 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

Definition at line 67 of file juce_MouseInputSource.cpp.

◆ forceMouseCursorUpdate()

void juce::MouseInputSource::forceMouseCursorUpdate ( )

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

Definition at line 74 of file juce_MouseInputSource.cpp.

◆ getComponentUnderMouse()

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

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

Definition at line 59 of file juce_MouseInputSource.cpp.

◆ getCurrentModifiers()

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

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

Definition at line 50 of file juce_MouseInputSource.cpp.

◆ 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.

Definition at line 53 of file juce_MouseInputSource.cpp.

◆ 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.

Definition at line 51 of file juce_MouseInputSource.cpp.

◆ 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.

Definition at line 55 of file juce_MouseInputSource.cpp.

◆ 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.

Definition at line 57 of file juce_MouseInputSource.cpp.

◆ 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.

Definition at line 46 of file juce_MouseInputSource.cpp.

◆ getLastMouseDownPosition()

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

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

Definition at line 63 of file juce_MouseInputSource.cpp.

◆ getLastMouseDownTime()

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

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

Definition at line 62 of file juce_MouseInputSource.cpp.

◆ 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.

Definition at line 61 of file juce_MouseInputSource.cpp.

◆ getRawScreenPosition()

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

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

Definition at line 49 of file juce_MouseInputSource.cpp.

◆ getScreenPosition()

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

Returns the last-known screen position of this source.

Definition at line 48 of file juce_MouseInputSource.cpp.

◆ getType()

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

Returns the type of input source that this object represents.

Definition at line 40 of file juce_MouseInputSource.cpp.

◆ hasMouseCursor()

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

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

Definition at line 70 of file juce_MouseInputSource.cpp.

◆ hasMouseWheel()

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

Returns true if this source may have a scroll wheel.

Definition at line 45 of file juce_MouseInputSource.cpp.

◆ 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.

Definition at line 65 of file juce_MouseInputSource.cpp.

◆ hideCursor()

void juce::MouseInputSource::hideCursor ( )

Hides the mouse cursor (if there is one).

Definition at line 72 of file juce_MouseInputSource.cpp.

◆ isDragging()

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

Returns true if this device is currently being pressed.

Definition at line 47 of file juce_MouseInputSource.cpp.

◆ 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.

Definition at line 64 of file juce_MouseInputSource.cpp.

◆ isMouse()

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

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

Definition at line 41 of file juce_MouseInputSource.cpp.

◆ isOrientationValid()

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

Returns true if the current orientation value is meaningful.

Definition at line 54 of file juce_MouseInputSource.cpp.

◆ isPen()

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

Returns true if this object represents a pen device.

Definition at line 43 of file juce_MouseInputSource.cpp.

◆ isPressureValid()

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

Returns true if the current pressure value is meaningful.

Definition at line 52 of file juce_MouseInputSource.cpp.

◆ isRotationValid()

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

Returns true if the current rotation value is meaningful.

Definition at line 56 of file juce_MouseInputSource.cpp.

◆ isTiltValid()

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

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

Definition at line 58 of file juce_MouseInputSource.cpp.

◆ isTouch()

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

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

Definition at line 42 of file juce_MouseInputSource.cpp.

◆ isUnboundedMouseMovementEnabled()

bool juce::MouseInputSource::isUnboundedMouseMovementEnabled ( ) const

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

Definition at line 69 of file juce_MouseInputSource.cpp.

◆ operator!=()

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

Definition at line 69 of file juce_MouseInputSource.h.

◆ operator=()

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

Definition at line 34 of file juce_MouseInputSource.cpp.

◆ operator==()

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

Definition at line 68 of file juce_MouseInputSource.h.

◆ revealCursor()

void juce::MouseInputSource::revealCursor ( )

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

Definition at line 73 of file juce_MouseInputSource.cpp.

◆ setScreenPosition()

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

Attempts to set this mouse pointer's screen position.

Definition at line 75 of file juce_MouseInputSource.cpp.

◆ showMouseCursor()

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

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

Definition at line 71 of file juce_MouseInputSource.cpp.

◆ 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.

Definition at line 60 of file juce_MouseInputSource.cpp.

Friends And Related Symbol Documentation

◆ ComponentPeer

friend class ComponentPeer
friend

Definition at line 289 of file juce_MouseInputSource.h.

◆ Desktop

friend class Desktop
friend

Definition at line 290 of file juce_MouseInputSource.h.

◆ detail::MouseInputSourceImpl

Definition at line 292 of file juce_MouseInputSource.h.

◆ detail::MouseInputSourceList

Definition at line 291 of file juce_MouseInputSource.h.

Member Data Documentation

◆ defaultOrientation

constexpr float juce::MouseInputSource::defaultOrientation
staticconstexpr

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

Definition at line 230 of file juce_MouseInputSource.h.

◆ defaultPressure

constexpr float juce::MouseInputSource::defaultPressure
staticconstexpr

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

Definition at line 227 of file juce_MouseInputSource.h.

◆ defaultRotation

constexpr float juce::MouseInputSource::defaultRotation
staticconstexpr

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

Definition at line 233 of file juce_MouseInputSource.h.

◆ defaultTiltX

constexpr float juce::MouseInputSource::defaultTiltX
staticconstexpr

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

Definition at line 236 of file juce_MouseInputSource.h.

◆ defaultTiltY

constexpr float juce::MouseInputSource::defaultTiltY
staticconstexpr

Definition at line 237 of file juce_MouseInputSource.h.

◆ invalidOrientation

const float juce::MouseInputSource::invalidOrientation
static

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

This is a valid value, returning true when calling isOrientationValid() hence the deprecation. Use defaultOrientation instead.

Definition at line 253 of file juce_MouseInputSource.h.

◆ invalidPressure

const float juce::MouseInputSource::invalidPressure
static

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

This is a valid value, returning true when calling isPressureValid() hence the deprecation. Use defaultPressure instead.

Definition at line 245 of file juce_MouseInputSource.h.

◆ invalidRotation

const float juce::MouseInputSource::invalidRotation
static

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

This is a valid value, returning true when calling isRotationValid() hence the deprecation. Use defaultRotation instead.

Definition at line 261 of file juce_MouseInputSource.h.

◆ invalidTiltX

const float juce::MouseInputSource::invalidTiltX
static

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

These are valid values, returning true when calling isTiltValid() hence the deprecation. Use defaultTiltX and defaultTiltY instead.

Definition at line 269 of file juce_MouseInputSource.h.

◆ invalidTiltY

const float juce::MouseInputSource::invalidTiltY
static

Definition at line 271 of file juce_MouseInputSource.h.

◆ offscreenMousePos

const Point< float > juce::MouseInputSource::offscreenMousePos
static

An offscreen mouse position used when triggering mouse exits where we don't want to move the cursor over an existing component.

Definition at line 276 of file juce_MouseInputSource.h.


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