JUCE
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
Public Member Functions
MouseInputSource Class Reference

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

List of all members.

Public Member Functions

 MouseInputSource (int index, bool isMouseDevice)
 Creates a MouseInputSource.
 ~MouseInputSource ()
 Destructor.
bool isMouse () const
 Returns true if this object represents a normal desk-based mouse device.
bool isTouch () const
 Returns true if this object represents a source of touch events - i.e.
bool canHover () const
 Returns true if this source has an on-screen pointer that can hover over items without clicking them.
bool hasMouseWheel () const
 Returns true if this source may have a scroll wheel.
int getIndex () const
 Returns this source's index in the global list of possible sources.
bool isDragging () const
 Returns true if this device is currently being pressed.
Point< int > getScreenPosition () const
 Returns the last-known screen position of this source.
ModifierKeys getCurrentModifiers () const
 Returns a set of modifiers that indicate which buttons are currently held down on this device.
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< int > getLastMouseDownPosition () const noexcept
 Returns the screen position at which the last mouse-down occurred.
bool hasMouseMovedSignificantlySincePressed () const noexcept
 Returns true if this mouse is currently down, and if it 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)
 Allows the mouse to move beyond the edges of the screen.
void handleEvent (ComponentPeer *peer, const Point< int > &positionWithinPeer, int64 time, const ModifierKeys &mods)
void handleWheel (ComponentPeer *peer, const Point< int > &positionWithinPeer, int64 time, float x, float y)

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

Constructor & Destructor Documentation

MouseInputSource::MouseInputSource ( int  index,
bool  isMouseDevice 
)

Creates a MouseInputSource.

You should never actually create a MouseInputSource in your own code - the library takes care of managing these objects.

Destructor.


Member Function Documentation

bool MouseInputSource::isMouse ( ) const

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

bool MouseInputSource::isTouch ( ) const

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

a finger or stylus.

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

Returns true if this source may have a scroll wheel.

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.

Returns true if this device is currently being pressed.

Returns the last-known screen position of this source.

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

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

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

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

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.

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

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

Returns true if this mouse is currently down, and if it has been dragged more than a couple of pixels from the place it was pressed.

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

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

Hides the mouse cursor (if there is one).

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

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

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

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

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 co-ordinates 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
void MouseInputSource::handleEvent ( ComponentPeer peer,
const Point< int > &  positionWithinPeer,
int64  time,
const ModifierKeys mods 
)
void MouseInputSource::handleWheel ( ComponentPeer peer,
const Point< int > &  positionWithinPeer,
int64  time,
float  x,
float  y 
)

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