Skip to content

Docs Module Mouse

Carlonn Rivers edited this page Sep 5, 2021 · 5 revisions

Mouse

Properties

Property Description Mouse Code Shortcut Identifier
type The flobtive's description type.
readonly
_visible A value that indicates whether the mouse's cursor is visible.
readonly
LEFT The mouse code property for the left mouse button 0 "left"
MIDDLE The mouse code property for the scroll wheel button 1 "middle"
RIGHT The mouse code property for the right mouse button 2 "right"

Method Summary

Method Description
hide() Hides the mouse cursor.
isDown() Checks if the mouse button specified is down or not.
isPressed() Checks if the mouse button specified is pressed or not.
isReleased() Checks if the mouse button specified is released or not.
isUp() Checks if the mouse button specified is up or not.
lock() Locks the cursor to the application.
show() Shows the mouse cursor.
unlock() Unlocks the cursor from the application.

Methods

hide()

Hides the mouse cursor.

Notes

  • The mouse cursor would only be hidden when in the bounds of the application.

Example

Assuming const Mouse = flevar.Mouse;

/* Within a script or function */

// check if the left mouse button is down
if(Mouse.isDown(0)) {
    // hide the mouse cursor
    Mouse.hide();
}

isDown(code)

Checks if the mouse button specified is down or not.

Parameters

  • code
    • Types: number | string
      • number: The mouse code value assigned to a specific mouse button or a Mouse module property associated with a specific mouse button.
      • string: The Mouse module property's shortcut identifier associated with a specific mouse button.

Returns

  • Type: boolean
    • true if the mouse button specified is down; false otherwise.

Notes

  • A FlevaR application can only monitor mouse events that occur within its focus. A FlevaR application cannot detect mouse events in another application.

Example

Assuming const Mouse = flevar.Mouse;

Using the mouse code:

/* Within a script or function added to a prefab */

// check if the left mouse button is down
if(Mouse.isDown(0)) {
    // move the prefab to the left
    prefab._x -= 8;
}

Using a Mouse module property:

/* Within a script or function added to a prefab */

// check if the left mouse button is down
if(Mouse.isDown(Mouse.LEFT)) {
    // move the prefab to the left
    prefab._x -= 8;
}

Using a Mouse module property's shortcut identifier:

/* Within a script or function added to a prefab */

// check if the left mouse button is down
if(Mouse.isDown("left")) {
    // move the prefab to the left
    prefab._x -= 8;
}

isPressed(code)

Checks if the mouse button specified is pressed or not.

Parameters

  • code
    • Types: number | string
      • number: The mouse code value assigned to a specific mouse button or a Mouse module property associated with a specific mouse button.
      • string: The Mouse module property's shortcut identifier associated with a specific mouse button.

Returns

  • Type: boolean
    • true if the mouse button specified is pressed; false otherwise.

Notes

  • A FlevaR application can only monitor mouse events that occur within its focus. A FlevaR application cannot detect mouse events in another application.
  • When a mouse button is pressed and captured in the script, the mouse button must be released before isPressed is true again.

Example

Assuming const Mouse = flevar.Mouse;

Using the mouse code:

/* Within a script or function */

// check if the scroll wheel button is pressed
if(Mouse.isPressed(1)) {
    flevar.trace(`Scroll wheel button is pressed!`);
}

Using a Mouse module property:

/* Within a script or function */

// check if the scroll wheel button is pressed
if(Mouse.isPressed(Mouse.MIDDLE)) {
    flevar.trace(`Scroll wheel button is pressed!`);
}

Using a Mouse module property's shortcut identifier:

/* Within a script or function */

// check if the scroll wheel button is pressed
if(Mouse.isPressed("middle")) {
    flevar.trace(`Scroll wheel button is pressed!`);
}

isReleased(code)

Checks if the mouse button specified is released or not.

Parameters

  • code
    • Types: number | string
      • number: The mouse code value assigned to a specific mouse button or a Mouse module property associated with a specific mouse button.
      • string: The Mouse module property's shortcut identifier associated with a specific mouse button.

Returns

  • Type: boolean
    • true if the mouse button specified is released; false otherwise.

Notes

  • A FlevaR application can only monitor mouse events that occur within its focus. A FlevaR application cannot detect mouse events in another application.
  • When a mouse button is released and captured in the script, the mouse button must be pressed before isReleased is true again.

Example

Assuming const Mouse = flevar.Mouse;

Using the mouse code:

/* Within a script or function */

// check if the right mouse button is released
if(Mouse.isReleased(2)) {
    // takes screenshot of application
    flevar.meta.takeScreenshot();
}

Using a Mouse module property:

/* Within a script or function */

// check if the right mouse button is released
if(Mouse.isReleased(Mouse.RIGHT)) {
    // takes screenshot of application
    flevar.meta.takeScreenshot();
}

Using a Mouse module property's shortcut identifier:

/* Within a script or function */

// check if the right mouse button is released
if(Mouse.isReleased("right")) {
    // takes screenshot of application
    flevar.meta.takeScreenshot();
}

isUp(code)

Checks if the mouse button specified is up or not.

Parameters

  • code
    • Types: number | string
      • number: The mouse code value assigned to a specific mouse button or a Mouse module property associated with a specific mouse button.
      • string: The Mouse module property's shortcut identifier associated with a specific mouse button.

Returns

  • Type: boolean
    • true if the mouse button specified is up; false otherwise.

Notes

  • A FlevaR application can only monitor mouse events that occur within its focus. A FlevaR application cannot detect mouse events in another application.

Example

Assuming const Mouse = flevar.Mouse;

Using the mouse code:

/* Within a script or function */

// check if the left mouse button is up
if(Mouse.isUp(0)) {
    flevar.trace(`Not holding "Left Click"`);
}

Using a Mouse module property:

/* Within a script or function */

// check if the left mouse button is up
if(Mouse.isUp(Mouse.LEFT)) {
    flevar.trace(`Not holding "Left Click"`);
}

Using a Mouse module property's shortcut identifier:

/* Within a script or function */

// check if the left mouse button is up
if(Mouse.isUp("left")) {
    flevar.trace(`Not holding "Left Click"`);
}

lock(type)

Locks/Traps the cursor to the application.

Parameters

  • type
    • Type: boolean
    • Default: true
    • Determines whether mouse cursor is restricted to the application's borders (true) or if they freely loop from one side of the application to the other, when exceeding its bounds (false).

Notes

  • Positions the mouse coordinates in the application's center on method call.

Example

Assuming const Mouse = flevar.Mouse;

/* Within a script or function */

// check if the scroll wheel button is pressed
if(Mouse.isPressed(1)) {
    // lock mouse cursor to the application and restrict its movement to application borders
    Mouse.lock(true);
}

show()

Shows the mouse cursor.

Example

Assuming const Mouse = flevar.Mouse;

/* Within a script or function */

// check if the right mouse button is down
if(Mouse.isDown(2)) {
    // show the mouse cursor
    Mouse.show();
}

unlock()

Unlocks/Untraps the cursor from the application.

Example

Assuming const Mouse = flevar.Mouse;

/* Within a script or function */

// check if the scroll wheel button is released
if(Mouse.isReleased(1)) {
    // unlock mouse cursor from the application
    Mouse.unlock();
}