MouseMove

From LoTROInterface Wiki

Jump to: navigation, search


Event fired when the mouse moves.

Syntax

Lua
function Control:MouseMove(sender, args);

Parameters

sender
Type: table
The event sender.


args
Type: table
The event arguments

  • args.X, args.Y: Integers. Contain the coordinates of the mouse event relative to the upper-left corner of sender.

Remarks

Note that if you are dragging the window with your mouse, so that the position of the window is changing, that args.X and args.Y are the coordinates from the current position of the window, not the original position.

Here is some sample code to drag a window Window around the screen.


Lua

Window.MouseDown = function(sender, args)
 sender.mousedown = true --this isn't a built-in parameter, but one we are using for this code
 sender.shiftX = args.X
 sender.shiftY = args.Y
end

Window.MouseMove = function(sender, args)
 if sender.mousedown then
  local currentX, currentY = sender:GetPosition() --the *current* position of the window, not the original
  local newX = currentX + (args.X - sender.shiftX)
  local newY = currentY + (args.Y - sender.shiftY)
  sender:SetPosition(newX, newY)
 end
end

Window.MouseUp = function(sender, args)
 sender.mousedown = false
end


If you omit sender.shiftX and sender.shiftY, it will still work, but the upper-left corner of the window will remain under the pointer regardless of where you clicked on it initially.

Personal tools