Mouse Class

 

About Mouse Class

 

Mouse class is mainly used for managing mouse inputs for specific windows. Note that you must still use Input class for managing inputs for Unity window.

 

Mouse Class Methods

 

Mouse.Clear( long WindowHandle ) clears all mouse states for the given window.

long WindowHandle: window handle.

 

Mouse.GetButton( long WindowHandle, long Button ) returns true if the specified button is held down or false otherwise.

long WindowHandle: window handle.
long Button: this parameter can be 0 for left button, 1 for right button, 2 for the middle button.

 

Mouse.SetButtonDown( long WindowHandle, long Button ) simulates a button press.

long WindowHandle: window handle.
long Button: this parameter can be 0 for left button, 1 for right button, 2 for the middle button.

 

Mouse.GetButtonDown( long WindowHandle, long Button ) returns true when the user starts pressing down the specified button or false otherwise.

long WindowHandle: window handle.
long Button: this parameter can be 0 for left button, 1 for right button, 2 for the middle button.

 

Mouse.SetButtonUp( long WindowHandle, long Button ) simulates a button release.

long WindowHandle: window handle.
long Button: this parameter can be 0 for left button, 1 for right button, 2 for the middle button.

 

Mouse.GetButtonUp( long WindowHandle, long Button ) returns true when the user releases the specified button or false otherwise.

long WindowHandle: window handle.
long Button: this parameter can be 0 for left button, 1 for right button, 2 for the middle button.

 

Mouse.SetButtonDoubleClicked( long WindowHandle, long Button ) simulates a double button click.

long WindowHandle: window handle.
long Button: this parameter can be 0 for left button, 1 for right button, 2 for the middle button.

 

Mouse.GetButtonDoubleClicked( long WindowHandle, long Button ) returns true when the user double clicks the specified button or false otherwise.

long WindowHandle: window handle.
long Button: this parameter can be 0 for left button, 1 for right button, 2 for the middle button.

 

Mouse.SetWheelUp( long WindowHandle ) simulates the rotation of the mouse wheel upwards.

long WindowHandle: window handle.

 

Mouse.GetWheelUp( long WindowHandle ) returns true when the user rotates the mouse wheel upwards or false otherwise.

long WindowHandle: window handle.

 

Mouse.SetWheelDown( long WindowHandle ) simulates the rotation of the mouse wheel downwards.

long WindowHandle: window handle.

 

Mouse.GetWheelDown( long WindowHandle ) returns true when the user rotates the mouse wheel downwards or false otherwise.

long WindowHandle: window handle.

 

Code Example

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Giavapps.Windows.API;

public class CodeExample : MonoBehaviour
{

private long WindowHandle = 0;

void Start()
{
Plugin.Initialize();//Initializes Giavapps Windows API
WindowHandle = Window.Create(0, 100, 100, 400, 400, Constant.WS_VISIBLE | Constant.WS_SYSMENU | Constant.WS_MINIMIZEBOX | Constant.WS_MAXIMIZEBOX | Constant.WS_SIZEBOX, Constant.WS_EX_TOPMOST);//Creates a new window
Control.SetText(WindowHandle, "Giavapps Windows API");//Sets a new title for the specified window
}

void Update()
{

//Checks if the specified window has been closed
if(Window.GetClosed(WindowHandle))
{
Control.Destroy(WindowHandle);//Destroys the specified window
}

//Checks if the specified mouse button has been pressed
if(Mouse.GetButtonDown(WindowHandle, 0))
{
Debug.Log("LEFT MOUSE BUTTON PRESSED!");
}
//Checks if the specified Mouse button has been released
else if(Mouse.GetButtonUp(WindowHandle, 0))
{
Debug.Log("LEFT MOUSE BUTTON RELEASED!");
}

}

void OnApplicationQuit()
{
Plugin.Deinitialize();//Deinitializes Giavapps Windows API
}

}

 

I am Luigi Piscopo, also known as DJ GiDeejay / Producer / Remixer in the music world. I am a Producer with a lot of experience in photo editing, video editing, audio editing, graphic design, web design, programming and promotion.

Comments are closed.