- Joined
- Aug 3, 2004
- Messages
- 710
MouseAPI allows getting and setting mouse coordinates. These aren't relative to the game, but just the screen coordinates.
Download: N/A Part of official Release
Native Set Type: Single Player or WarSoc
Release: 0.02alpha, updated in 0.10
Example usage:
JASS:
native GetMouseX takes nothing returns integer
native GetMouseY takes nothing returns integer
native GetMouseXRelative takes nothing returns integer
native GetMouseYRelative takes nothing returns integer
native SetMouseX takes integer x returns nothing
native SetMouseY takes integer y returns nothing
native SetMousePos takes integer x, integer y returns nothing
//
//===================================================
// Mouse API constants
//===================================================
constant integer EVENT_LMOUSEUP = 0
constant integer EVENT_LMOUSEDOWN = 1
constant integer EVENT_RMOUSEUP = 2
constant integer EVENT_RMOUSEDOWN = 3
constant integer EVENT_MMOUSEUP = 4
constant integer EVENT_MMOUSEDOWN = 5
constant integer EVENT_MOUSEWHEEL = 6
// New Functions
native TriggerRegisterMouseEvent takes trigger whichTrigger, integer eventtype returns nothing
native GetTriggerWheelDelta takes nothing returns integer
Download: N/A Part of official Release
Native Set Type: Single Player or WarSoc
Release: 0.02alpha, updated in 0.10
GetMouseX
Gets the X component of the mouse position.GetMouseY
Gets the Y component of the mouse position.GetMouseXRelative
Gets the X component of the mouse position relative to the window.GetMouseYRelative
Gets the Y component of the mouse position relative to the window.SetMouseX
Sets the X component of the mouse position.SetMouseY
Sets the Y component of the mouse position.SetMousePos
Sets the X and Y component of the mouse position, faster if you need to move both at once.Example usage:
JASS:
local integer mx = GetMouseX()
local integer my = GetMouseY()
local integer vx = GetWindowWidth()/2 //GetWindowWidth is part of WindowAPI
local integer vy = GetWindowHeight()/2 //GetWindowHeight is part of WindowAPI
set vx = vx-mx
set vy = vy-my
//now you can use vx and vy as offset variables to move things. Like a unit.
call SetMouseX(GetWindowWidth()/2) //GetWindowWidth is part of WindowAPI
call SetMouseY(GetWindowHeight()/2) //GetWindowHeight is part of WindowAPI
Last edited: