Difference between revisions of "$mouse"

From Scriptwiki
Jump to: navigation, search
m (added $mouse)
 
m (Added .cx/.cy)
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''$mouse'''<br />
+
[[image:Mouse.png|right|thumb|200px|Differences between $mouse.x/y .mx/my and .dx/dy]]
Properties: win, x, y, mx, my, dx, dy, key, lb
 
 
 
 
Returns the x, y position of the current mouse event, and whether the left mouse button, shift key, and/or control key are pressed.
 
Returns the x, y position of the current mouse event, and whether the left mouse button, shift key, and/or control key are pressed.
 
The $mouse identifier can be used in the mouse/click events.  
 
The $mouse identifier can be used in the mouse/click events.  
 +
 +
$mouse
 +
 +
Properties:
 +
.win    property returns the name of the active window.
 +
.x/.y    returns mouse x- and y-coordinates relative to active window.
 +
.mx/.my  returns mouse x- and y-coordinates relative to mirc window.
 +
.dx/.dy  returns mouse x- and y-coordinates relative to desktop.
 +
.cx/.cy  returns mouse x- and y-coordinates relative to primary monitor. (Use for multi-monitor purposes rather than .dx/.dy.)
 +
.lb      property returns $true if a mouse event occurred over a listbox, or $false if it didn't.
 +
.key    returns a bitwise value of the key(s) being pressed.
  
 
For $mouse.key you can use the & bitwise operator to check if the left button, shift key, and/or control key are pressed:
 
For $mouse.key you can use the & bitwise operator to check if the left button, shift key, and/or control key are pressed:
Line 12: Line 21:
 
  if ($mouse.key & 16) echo right mouse button is pressed.
 
  if ($mouse.key & 16) echo right mouse button is pressed.
  
Properties:
+
The following menu commands are available for mouse actions:
  .win    property returns the name of the active window.
+
  mouse:  triggers when mouse moves in a window
  .x/.y    returns mouse x- and y-coordinates relative to active window
+
  sclick:  triggers on single left-click (mouse1; left button)
  .mx/.my returns mouse x- and y-coordinates relative to mirc window
+
  dclick:  triggers on double click (mouse1; left button)
  .dx/.dy returns mouse x- and y-coordinates relative to desktop
+
  uclick:  triggers when button is released inside window, triggers before drop (mouse1; left button)
  .lb      property returns $true if a mouse event occurred over a listbox, or $false if it didn't.
+
  rclick: triggers on single right-click (mouse2; right button)
 +
lbclick: triggers when user single clicks on window listbox
 +
  leave:  triggers when mouse moves outside from window area $leftwin = windowname, $leftwinwid = windowID
 +
drop:    triggers when button is released inside the window (mouse1; left button)
  
Example:
+
== Example ==
 
  ; First we'll need to create a picture window from editbox:
 
  ; First we'll need to create a picture window from editbox:
 
  ; -p means it's a picture window, first @test is the name of the window, the second @test is the name of the popupfile  
 
  ; -p means it's a picture window, first @test is the name of the window, the second @test is the name of the popupfile  
Line 44: Line 56:
 
   elseif ($mouse.key & 16) { drawdot @test $color(background) 6 $mouse.x $mouse.y }
 
   elseif ($mouse.key & 16) { drawdot @test $color(background) 6 $mouse.x $mouse.y }
 
  }
 
  }
 +
 +
== See Also ==
 +
* [[$click]] Stores a history of x/y clicks in a window.
 +
* [[Popup_Menus#MENU_prefix|Menu Prefix]] Various mouse events inside the custom menus.
 +
 +
[[Category:Mouse and Menu Identifiers]]

Latest revision as of 12:32, 8 July 2014

Differences between $mouse.x/y .mx/my and .dx/dy

Returns the x, y position of the current mouse event, and whether the left mouse button, shift key, and/or control key are pressed. The $mouse identifier can be used in the mouse/click events.

$mouse

Properties:

.win     property returns the name of the active window.
.x/.y    returns mouse x- and y-coordinates relative to active window.
.mx/.my  returns mouse x- and y-coordinates relative to mirc window.
.dx/.dy  returns mouse x- and y-coordinates relative to desktop.
.cx/.cy  returns mouse x- and y-coordinates relative to primary monitor. (Use for multi-monitor purposes rather than .dx/.dy.)
.lb      property returns $true if a mouse event occurred over a listbox, or $false if it didn't.
.key     returns a bitwise value of the key(s) being pressed.

For $mouse.key you can use the & bitwise operator to check if the left button, shift key, and/or control key are pressed:

if ($mouse.key & 1) echo left button is pressed.
if ($mouse.key & 2) echo control key is pressed.
if ($mouse.key & 4) echo shift key is pressed.
if ($mouse.key & 8) echo alt key is pressed.
if ($mouse.key & 16) echo right mouse button is pressed.

The following menu commands are available for mouse actions:

mouse:   triggers when mouse moves in a window
sclick:  triggers on single left-click (mouse1; left button)
dclick:  triggers on double click (mouse1; left button)
uclick:  triggers when button is released inside window, triggers before drop (mouse1; left button)
rclick:  triggers on single right-click (mouse2; right button)
lbclick: triggers when user single clicks on window listbox
leave:   triggers when mouse moves outside from window area $leftwin = windowname, $leftwinwid = windowID
drop:    triggers when button is released inside the window (mouse1; left button)

Example

; First we'll need to create a picture window from editbox:
; -p means it's a picture window, first @test is the name of the window, the second @test is the name of the popupfile 
; (we'll use the window's name so we can use the menu prefix in remote script)
/window -p @test @test

; the menu for our @test window
menu @test {
  ; "mouse" triggers whenever mouse moves in the window, and executes draw alias
  mouse:draw

  ; "dclick" triggers whenever user doubleclicks in the window, we'll use this to clear the window
  dclick:clear @test
}

; this is the alias that is executed everytime mouse moves in @test window
alias draw { 
  ; an if to check if left mouse button is pressed, if so draw a dot into the window with colorcode 4, size 2px, 
  ; and read the X and Y location for the dot from $mouse.x and $mouse.y
  if ($mouse.key & 1) { drawdot @test 4 2 $mouse.x $mouse.y } 

  ; else if left mouse button wasn't pressed, see if right mouse button was
  ; we'll do the drawdot like earlier, but use background color as the color (erase) and make it a bit bigger
  elseif ($mouse.key & 16) { drawdot @test $color(background) 6 $mouse.x $mouse.y }
}

See Also

* $click Stores a history of x/y clicks in a window.
* Menu Prefix Various mouse events inside the custom menus.