Vuo  2.3.2
Classes | Functions | Variables
VuoMouse.m File Reference

Description

VuoMouse implementation.

Definition in file VuoMouse.m.

Go to the source code of this file.

Classes

category  NSEvent(VuoMouse)
 Defined in OS X 10.11 SDK but available on 10.10.3+. More...
 
struct  VuoMouseContext
 Handle for starting and stopping event listeners. More...
 

Functions

void VuoMouse_GetScreenDimensions (int64_t *width, int64_t *height)
 Get the full screen width and height in pixels. More...
 
static float VuoMouse_getPressure (NSEvent *event)
 Combines the event's pressure with its stage to produce a continuous pressure value. More...
 
VuoMouseVuoMouse_make (void)
 Creates a handle for starting and stopping event listeners. More...
 
static VuoPoint2d VuoMouse_convertWindowToScreenCoordinates (NSPoint pointInWindow, NSWindow *window, bool *shouldFire)
 Converts a position relative to the window into a position relative to the current screen. More...
 
static VuoPoint2d VuoMouse_convertViewToVuoCoordinates (NSPoint pointInView, NSView *view)
 Converts a position relative to a view and in view coordinates into a position in Vuo coordinates. More...
 
static VuoPoint2d VuoMouse_convertFullScreenToVuoCoordinates (NSPoint pointInScreen, NSWindow *window, bool *isInScreen)
 Converts a position in screen coordinates into a position relative to the the window's fullscreen view and in Vuo coordinates. More...
 
VuoPoint2d VuoMouse_convertWindowToVuoCoordinates (NSPoint pointInWindow, NSWindow *window, bool *shouldFire)
 Converts a position relative to the window and in window coordinates into a position relative to the window's content view and in Vuo coordinates. More...
 
static VuoPoint2d VuoMouse_convertDeltaToVuoCoordinates (NSPoint delta, NSWindow *window)
 Converts a change in position in window coordinates into a change in position in Vuo coordinates. More...
 
bool VuoMouse_isResizing (void)
 Returns true if the mouse is potentially involved in a window resize (and thus we should ignore the button). More...
 
static void VuoMouse_fireScrollDeltaIfNeeded (NSEvent *event, VuoWindowReference windowRef, VuoModifierKey modifierKey, void(^scrolled)(VuoPoint2d))
 If the mouse was scrolled a non-zero amount, calls the trigger function and passes it the scroll delta. More...
 
static void VuoMouse_fireMousePositionIfNeeded (NSEvent *event, NSPoint fullscreenPoint, VuoWindowReference windowRef, VuoModifierKey modifierKey, bool fireRegardlessOfPosition, bool fireRegardlessOfWindow, void(^fire)(VuoPoint2d))
 If the mouse event is not ignored, calls the block and passes it the mouse position. More...
 
static void VuoMouse_fireMouseDeltaIfNeeded (NSEvent *event, VuoWindowReference windowRef, VuoModifierKey modifierKey, void(*fire)(VuoPoint2d))
 If the mouse event is not ignored, calls the trigger function and passes it the mouse delta (change in position). More...
 
static void VuoMouse_fireMouseClickIfNeeded (struct VuoMouseContext *context, NSEvent *event, VuoWindowReference windowRef, VuoModifierKey modifierKey, void(*singleClicked)(VuoPoint2d), void(*doubleClicked)(VuoPoint2d), void(*tripleClicked)(VuoPoint2d))
 If the mouse click event is not ignored, calls the trigger function and passes it the mouse position. More...
 
void VuoMouse_startListeningForScrolls (VuoMouse *mouseListener, void(*scrolled)(VuoPoint2d), VuoWindowReference window, VuoModifierKey modifierKey)
 Starts listening for scroll events, and calling the trigger function for each one. More...
 
void VuoMouse_startListeningForScrollsWithCallback (VuoMouse *mouseListener, void(^scrolled)(VuoPoint2d), VuoWindowReference window, VuoModifierKey modifierKey)
 Starts listening for scroll events, and calling the scrolled block for each one. More...
 
static void VuoMouse_fireInitialEvent (void(^movedTo)(VuoPoint2d), VuoWindowReference window, VuoModifierKey modifierKey)
 If window is non-NULL and modifierKey is Any or None, invokes movedTo with the mouse's current position. More...
 
void VuoMouse_startListeningForMoves (VuoMouse *mouseListener, void(*movedTo)(VuoPoint2d), VuoWindowReference window, VuoModifierKey modifierKey, bool global)
 Starts listening for mouse move events, and calling the trigger function (with mouse position) for each one,. More...
 
void VuoMouse_startListeningForMovesWithCallback (VuoMouse *mouseListener, void(^movedTo)(VuoPoint2d), VuoWindowReference window, VuoModifierKey modifierKey)
 Starts listening for mouse move events, and calling the given block for each one. More...
 
void VuoMouse_startListeningForDeltas (VuoMouse *mouseListener, void(*movedBy)(VuoPoint2d), VuoWindowReference window, VuoModifierKey modifierKey)
 Starts listening for mouse move events, and calling the trigger function (with change in mouse position) for each one. More...
 
void VuoMouse_startListeningForDragsWithCallback (VuoMouse *mouseListener, void(^dragMovedTo)(VuoPoint2d), VuoMouseButton button, VuoWindowReference window, VuoModifierKey modifierKey, bool fireRegardlessOfPosition)
 Starts listening for mouse drag events, and calling the given block for each one. More...
 
void VuoMouse_startListeningForDrags (VuoMouse *mouseListener, void(*dragMovedTo)(VuoPoint2d), VuoMouseButton button, VuoWindowReference window, VuoModifierKey modifierKey)
 Starts listening for mouse drag events, and calling the trigger function for each one. More...
 
void VuoMouse_startListeningForPressesWithCallback (VuoMouse *mouseListener, void(^pressed)(VuoPoint2d), void(^forcePressed)(VuoPoint2d), VuoMouseButton button, VuoWindowReference window, VuoModifierKey modifierKey)
 Starts listening for mouse press events, and calling the given block for each one. More...
 
void VuoMouse_startListeningForPresses (VuoMouse *mouseListener, void(*pressed)(VuoPoint2d), void(*forcePressed)(VuoPoint2d), VuoMouseButton button, VuoWindowReference window, VuoModifierKey modifierKey)
 Starts listening for mouse press events, and calling the trigger function for each one. More...
 
void VuoMouse_startListeningForPressureChanges (VuoMouse *mouseListener, void(*pressureChanged)(VuoReal), VuoMouseButton button, VuoModifierKey modifierKey)
 Starts listening for mouse pressure-change events, and calling the trigger function for each one. More...
 
void VuoMouse_startListeningForReleasesWithCallback (VuoMouse *mouseListener, void(^released)(VuoPoint2d), VuoMouseButton button, VuoWindowReference window, VuoModifierKey modifierKey, bool fireRegardlessOfPosition)
 Starts listening for mouse release events, and calling the given block for each one. More...
 
void VuoMouse_startListeningForReleases (VuoMouse *mouseListener, void(*released)(VuoPoint2d), VuoMouseButton button, VuoWindowReference window, VuoModifierKey modifierKey, bool fireRegardlessOfPosition)
 Starts listening for mouse release events, and calling the trigger function for each one. More...
 
void VuoMouse_startListeningForClicks (VuoMouse *mouseListener, void(*singleClicked)(VuoPoint2d), void(*doubleClicked)(VuoPoint2d), void(*tripleClicked)(VuoPoint2d), VuoMouseButton button, VuoWindowReference window, VuoModifierKey modifierKey)
 Starts listening for mouse click events, and calling the trigger function for each one. More...
 
void VuoMouse_startListeningForTouches (VuoMouse *mouseListener, void(*touchesMoved)(VuoList_VuoPoint2d), void(*zoomed)(VuoReal), void(*swipedLeft)(void), void(*swipedRight)(void), VuoWindowReference windowRef)
 Starts listening for touch events, and calling the trigger function for each one. More...
 
void VuoMouse_stopListening (VuoMouse *mouseListener)
 Stops listening for mouse events for the given handle. More...
 
void VuoMouseStatus_use (void)
 Starts tracking mouse events to later be reported by VuoMouse_getStatus. More...
 
void VuoMouseStatus_disuse (void)
 Stops tracking mouse events for VuoMouse_getStatus. More...
 
bool VuoMouse_getStatus (VuoPoint2d *position, VuoBoolean *isPressed, VuoMouseButton button, VuoWindowReference windowRef, VuoModifierKey modifierKey, bool onlyUpdateWhenActive)
 Outputs the current mouse position and whether the mouse is currently pressed. More...
 

Variables

const int NSEventTypePressure = 34
 Defined in OS X 10.11 SDK but available on 10.10.3+. More...
 
const uint64_t NSEventMaskPressure = 1ULL << NSEventTypePressure
 Defined in OS X 10.11 SDK but available on 10.10.3+. More...
 
static unsigned int VuoMouseStatus_useCount = 0
 Process-wide count of callers (typically node instances) using VuoMouse_getStatus. More...
 
static id VuoMouseStatus_monitor = nil
 Process-wide mouse event monitor for VuoMouse_getStatus. More...
 
static NSPoint VuoMouseStatus_position
 The mouse's position in screen coordinates, as reported by the most recent non-filtered event. More...
 
static bool VuoMouseStatus_leftButton = false
 The mouse's current button status, as reported by recent non-filtered events. More...
 
static bool VuoMouseStatus_middleButton = false
 The mouse's current button status, as reported by recent non-filtered events. More...
 
static bool VuoMouseStatus_rightButton = false
 The mouse's current button status, as reported by recent non-filtered events. More...
 

Function Documentation

◆ VuoMouse_convertDeltaToVuoCoordinates()

static VuoPoint2d VuoMouse_convertDeltaToVuoCoordinates ( NSPoint  delta,
NSWindow *  window 
)
static

Converts a change in position in window coordinates into a change in position in Vuo coordinates.

Definition at line 237 of file VuoMouse.m.

◆ VuoMouse_convertFullScreenToVuoCoordinates()

static VuoPoint2d VuoMouse_convertFullScreenToVuoCoordinates ( NSPoint  pointInScreen,
NSWindow *  window,
bool *  isInScreen 
)
static

Converts a position in screen coordinates into a position relative to the the window's fullscreen view and in Vuo coordinates.

Definition at line 185 of file VuoMouse.m.

◆ VuoMouse_convertViewToVuoCoordinates()

static VuoPoint2d VuoMouse_convertViewToVuoCoordinates ( NSPoint  pointInView,
NSView *  view 
)
static

Converts a position relative to a view and in view coordinates into a position in Vuo coordinates.

This function may be called from any thread.

Definition at line 155 of file VuoMouse.m.

◆ VuoMouse_convertWindowToScreenCoordinates()

static VuoPoint2d VuoMouse_convertWindowToScreenCoordinates ( NSPoint  pointInWindow,
NSWindow *  window,
bool *  shouldFire 
)
static

Converts a position relative to the window into a position relative to the current screen.

Definition at line 115 of file VuoMouse.m.

◆ VuoMouse_convertWindowToVuoCoordinates()

VuoPoint2d VuoMouse_convertWindowToVuoCoordinates ( NSPoint  pointInWindow,
NSWindow *  window,
bool *  shouldFire 
)

Converts a position relative to the window and in window coordinates into a position relative to the window's content view and in Vuo coordinates.

This function may be called from any thread.

Definition at line 209 of file VuoMouse.m.

◆ VuoMouse_fireInitialEvent()

static void VuoMouse_fireInitialEvent ( void(^)(VuoPoint2d)  movedTo,
VuoWindowReference  window,
VuoModifierKey  modifierKey 
)
static

If window is non-NULL and modifierKey is Any or None, invokes movedTo with the mouse's current position.

Definition at line 475 of file VuoMouse.m.

◆ VuoMouse_fireMouseClickIfNeeded()

static void VuoMouse_fireMouseClickIfNeeded ( struct VuoMouseContext context,
NSEvent *  event,
VuoWindowReference  windowRef,
VuoModifierKey  modifierKey,
void(*)(VuoPoint2d)  singleClicked,
void(*)(VuoPoint2d)  doubleClicked,
void(*)(VuoPoint2d)  tripleClicked 
)
static

If the mouse click event is not ignored, calls the trigger function and passes it the mouse position.

If a window is given, the mouse position is in Vuo coordinates relative to the window's content view. The mouse event is ignored if it doesn't correspond to this window.

If no window is given, the mouse position is in screen coordinates.

Definition at line 406 of file VuoMouse.m.

◆ VuoMouse_fireMouseDeltaIfNeeded()

static void VuoMouse_fireMouseDeltaIfNeeded ( NSEvent *  event,
VuoWindowReference  windowRef,
VuoModifierKey  modifierKey,
void(*)(VuoPoint2d)  fire 
)
static

If the mouse event is not ignored, calls the trigger function and passes it the mouse delta (change in position).

If a window is given, the mouse delta is in Vuo coordinates relative to the window's content view. The mouse event is ignored if it doesn't correspond to this window.

If no window is given, the mouse delta is in screen coordinates.

Definition at line 356 of file VuoMouse.m.

◆ VuoMouse_fireMousePositionIfNeeded()

static void VuoMouse_fireMousePositionIfNeeded ( NSEvent *  event,
NSPoint  fullscreenPoint,
VuoWindowReference  windowRef,
VuoModifierKey  modifierKey,
bool  fireRegardlessOfPosition,
bool  fireRegardlessOfWindow,
void(^)(VuoPoint2d)  fire 
)
static

If the mouse event is not ignored, calls the block and passes it the mouse position.

If a window is given, the mouse position is in Vuo coordinates relative to the window's content view. The mouse event is ignored if it doesn't correspond to this window (unless fireRegardlessOfWindow is true).

If no window is given, the mouse position is in screen coordinates.

Definition at line 297 of file VuoMouse.m.

◆ VuoMouse_fireScrollDeltaIfNeeded()

static void VuoMouse_fireScrollDeltaIfNeeded ( NSEvent *  event,
VuoWindowReference  windowRef,
VuoModifierKey  modifierKey,
void(^)(VuoPoint2d)  scrolled 
)
static

If the mouse was scrolled a non-zero amount, calls the trigger function and passes it the scroll delta.

Definition at line 266 of file VuoMouse.m.

◆ VuoMouse_getPressure()

static float VuoMouse_getPressure ( NSEvent *  event)
static

Combines the event's pressure with its stage to produce a continuous pressure value.

Definition at line 70 of file VuoMouse.m.

◆ VuoMouse_GetScreenDimensions()

void VuoMouse_GetScreenDimensions ( int64_t *  width,
int64_t *  height 
)

Get the full screen width and height in pixels.

This function may be called on any thread except the main thread.

Definition at line 55 of file VuoMouse.m.

◆ VuoMouse_getStatus()

bool VuoMouse_getStatus ( VuoPoint2d *  position,
VuoBoolean isPressed,
VuoMouseButton  button,
VuoWindowReference  windowRef,
VuoModifierKey  modifierKey,
bool  onlyUpdateWhenActive 
)

Outputs the current mouse position and whether the mouse is currently pressed.

If onlyUpdateWhenActive is true, and the application is not active, then neither position nor isPressed is modified.

If a window is given, but it's not the key window or the mouse is not within the window, then position is modified but isPressed is not.

If a window is given, the mouse position is in Vuo coordinates relative to the window's content view. Otherwise, the mouse position is in screen coordinates.

Returns true if position was updated.

This function may be called from any thread.

Definition at line 951 of file VuoMouse.m.

◆ VuoMouse_isResizing()

bool VuoMouse_isResizing ( void  )

Returns true if the mouse is potentially involved in a window resize (and thus we should ignore the button).

Definition at line 251 of file VuoMouse.m.

◆ VuoMouse_make()

VuoMouse* VuoMouse_make ( void  )

Creates a handle for starting and stopping event listeners.

Definition at line 100 of file VuoMouse.m.

◆ VuoMouse_startListeningForClicks()

void VuoMouse_startListeningForClicks ( VuoMouse mouseListener,
void(*)(VuoPoint2d)  singleClicked,
void(*)(VuoPoint2d)  doubleClicked,
void(*)(VuoPoint2d)  tripleClicked,
VuoMouseButton  button,
VuoWindowReference  window,
VuoModifierKey  modifierKey 
)

Starts listening for mouse click events, and calling the trigger function for each one.

This function may be called from any thread.

Definition at line 745 of file VuoMouse.m.

◆ VuoMouse_startListeningForDeltas()

void VuoMouse_startListeningForDeltas ( VuoMouse mouseListener,
void(*)(VuoPoint2d)  movedBy,
VuoWindowReference  window,
VuoModifierKey  modifierKey 
)

Starts listening for mouse move events, and calling the trigger function (with change in mouse position) for each one.

This function may be called from any thread.

Definition at line 541 of file VuoMouse.m.

◆ VuoMouse_startListeningForDrags()

void VuoMouse_startListeningForDrags ( VuoMouse mouseListener,
void(*)(VuoPoint2d)  dragMovedTo,
VuoMouseButton  button,
VuoWindowReference  window,
VuoModifierKey  modifierKey 
)

Starts listening for mouse drag events, and calling the trigger function for each one.

This function may be called from any thread.

Definition at line 597 of file VuoMouse.m.

◆ VuoMouse_startListeningForDragsWithCallback()

void VuoMouse_startListeningForDragsWithCallback ( VuoMouse mouseListener,
void(^)(VuoPoint2d)  dragMovedTo,
VuoMouseButton  button,
VuoWindowReference  window,
VuoModifierKey  modifierKey,
bool  fireRegardlessOfPosition 
)

Starts listening for mouse drag events, and calling the given block for each one.

This function may be called from any thread.

Definition at line 557 of file VuoMouse.m.

◆ VuoMouse_startListeningForMoves()

void VuoMouse_startListeningForMoves ( VuoMouse mouseListener,
void(*)(VuoPoint2d)  movedTo,
VuoWindowReference  window,
VuoModifierKey  modifierKey,
bool  global 
)

Starts listening for mouse move events, and calling the trigger function (with mouse position) for each one,.

If window is non-NULL and modifierKey is Any or None, immediately invokes movedTo with the mouse's current position.

This function may be called from any thread.

Definition at line 497 of file VuoMouse.m.

◆ VuoMouse_startListeningForMovesWithCallback()

void VuoMouse_startListeningForMovesWithCallback ( VuoMouse mouseListener,
void(^)(VuoPoint2d)  movedTo,
VuoWindowReference  window,
VuoModifierKey  modifierKey 
)

Starts listening for mouse move events, and calling the given block for each one.

If window is non-NULL and modifierKey is Any or None, immediately invokes movedTo with the mouse's current position.

This function may be called from any thread.

Definition at line 522 of file VuoMouse.m.

◆ VuoMouse_startListeningForPresses()

void VuoMouse_startListeningForPresses ( VuoMouse mouseListener,
void(*)(VuoPoint2d)  pressed,
void(*)(VuoPoint2d)  forcePressed,
VuoMouseButton  button,
VuoWindowReference  window,
VuoModifierKey  modifierKey 
)

Starts listening for mouse press events, and calling the trigger function for each one.

This function may be called from any thread.

Changed in Vuo 2.0.0:
Added forcePressed callback.

Definition at line 660 of file VuoMouse.m.

◆ VuoMouse_startListeningForPressesWithCallback()

void VuoMouse_startListeningForPressesWithCallback ( VuoMouse mouseListener,
void(^)(VuoPoint2d)  pressed,
void(^)(VuoPoint2d)  forcePressed,
VuoMouseButton  button,
VuoWindowReference  window,
VuoModifierKey  modifierKey 
)

Starts listening for mouse press events, and calling the given block for each one.

This function may be called from any thread.

Changed in Vuo 2.0.0:
Added forcePressed callback.

Definition at line 609 of file VuoMouse.m.

◆ VuoMouse_startListeningForPressureChanges()

void VuoMouse_startListeningForPressureChanges ( VuoMouse mouseListener,
void(*)(VuoReal pressureChanged,
VuoMouseButton  button,
VuoModifierKey  modifierKey 
)

Starts listening for mouse pressure-change events, and calling the trigger function for each one.

This function may be called from any thread.

Changed in Vuo 2.0.0:
New.

Definition at line 676 of file VuoMouse.m.

◆ VuoMouse_startListeningForReleases()

void VuoMouse_startListeningForReleases ( VuoMouse mouseListener,
void(*)(VuoPoint2d)  released,
VuoMouseButton  button,
VuoWindowReference  window,
VuoModifierKey  modifierKey,
bool  fireRegardlessOfPosition 
)

Starts listening for mouse release events, and calling the trigger function for each one.

This function may be called from any thread.

Definition at line 735 of file VuoMouse.m.

◆ VuoMouse_startListeningForReleasesWithCallback()

void VuoMouse_startListeningForReleasesWithCallback ( VuoMouse mouseListener,
void(^)(VuoPoint2d)  released,
VuoMouseButton  button,
VuoWindowReference  window,
VuoModifierKey  modifierKey,
bool  fireRegardlessOfPosition 
)

Starts listening for mouse release events, and calling the given block for each one.

This function may be called from any thread.

Definition at line 695 of file VuoMouse.m.

◆ VuoMouse_startListeningForScrolls()

void VuoMouse_startListeningForScrolls ( VuoMouse mouseListener,
void(*)(VuoPoint2d)  scrolled,
VuoWindowReference  window,
VuoModifierKey  modifierKey 
)

Starts listening for scroll events, and calling the trigger function for each one.

This function may be called from any thread.

Definition at line 445 of file VuoMouse.m.

◆ VuoMouse_startListeningForScrollsWithCallback()

void VuoMouse_startListeningForScrollsWithCallback ( VuoMouse mouseListener,
void(^)(VuoPoint2d)  scrolled,
VuoWindowReference  window,
VuoModifierKey  modifierKey 
)

Starts listening for scroll events, and calling the scrolled block for each one.

This function may be called from any thread.

Definition at line 461 of file VuoMouse.m.

◆ VuoMouse_startListeningForTouches()

void VuoMouse_startListeningForTouches ( VuoMouse mouseListener,
void(*)(VuoList_VuoPoint2d touchesMoved,
void(*)(VuoReal zoomed,
void(*)(void)  swipedLeft,
void(*)(void)  swipedRight,
VuoWindowReference  windowRef 
)

Starts listening for touch events, and calling the trigger function for each one.

This function may be called from any thread.

Changed in Vuo 2.0.0:
New.

Definition at line 790 of file VuoMouse.m.

◆ VuoMouse_stopListening()

void VuoMouse_stopListening ( VuoMouse mouseListener)

Stops listening for mouse events for the given handle.

This function may be called from any thread.

Definition at line 813 of file VuoMouse.m.

◆ VuoMouseStatus_disuse()

void VuoMouseStatus_disuse ( void  )

Stops tracking mouse events for VuoMouse_getStatus.

This function may be called from any thread.

Definition at line 927 of file VuoMouse.m.

◆ VuoMouseStatus_use()

void VuoMouseStatus_use ( void  )

Starts tracking mouse events to later be reported by VuoMouse_getStatus.

This function may be called from any thread.

Definition at line 873 of file VuoMouse.m.

Variable Documentation

◆ NSEventMaskPressure

const uint64_t NSEventMaskPressure = 1ULL << NSEventTypePressure

Defined in OS X 10.11 SDK but available on 10.10.3+.

Definition at line 18 of file VuoMouse.m.

◆ NSEventTypePressure

const int NSEventTypePressure = 34

Defined in OS X 10.11 SDK but available on 10.10.3+.

Definition at line 16 of file VuoMouse.m.

◆ VuoMouseStatus_leftButton

bool VuoMouseStatus_leftButton = false
static

The mouse's current button status, as reported by recent non-filtered events.

Definition at line 864 of file VuoMouse.m.

◆ VuoMouseStatus_middleButton

bool VuoMouseStatus_middleButton = false
static

The mouse's current button status, as reported by recent non-filtered events.

Definition at line 865 of file VuoMouse.m.

◆ VuoMouseStatus_monitor

id VuoMouseStatus_monitor = nil
static

Process-wide mouse event monitor for VuoMouse_getStatus.

Definition at line 862 of file VuoMouse.m.

◆ VuoMouseStatus_position

NSPoint VuoMouseStatus_position
static

The mouse's position in screen coordinates, as reported by the most recent non-filtered event.

Definition at line 863 of file VuoMouse.m.

◆ VuoMouseStatus_rightButton

bool VuoMouseStatus_rightButton = false
static

The mouse's current button status, as reported by recent non-filtered events.

Definition at line 866 of file VuoMouse.m.

◆ VuoMouseStatus_useCount

unsigned int VuoMouseStatus_useCount = 0
static

Process-wide count of callers (typically node instances) using VuoMouse_getStatus.

Definition at line 861 of file VuoMouse.m.