Skip to content
Benedict Allen edited this page Nov 15, 2015 · 1 revision

MouseEvent Class

The MouseEvent is used to pass mouse events to Sheets.

Extends Event

Constructor

Event creation is handled internally by Application.

MouseEvent( Event enum event, number x, number y, number button, boolean within = true )

within is whether the event is within the bounds of the parent object of the one handling the event.

Properties

x

MouseEvent.x - number

The relative X position of the event.

y

MouseEvent.y - number

The relative Y position of the event.

button

MouseEvent.button - number

The button of the event.

within

MouseEvent.within - boolean

Whether the event is within the bounds of the parent object to the one handling the event.

Methods

isWithinArea()

boolean within = MouseEvent:isWithinArea( number x, number y, number width, number height )

Returns whether the event is within the area given. Note that, as mouse events are localised, to check if the event is within a Sheet, x and y should both be 0. Also note, this doesn't take the within parameter into account. That must be done manually.

clone()

MouseEvent e = MouseEvent:clone( number x, number y, boolean within )

Returns a cloned event, with modified coordinates and within state, which can be passed to children. within should be whether the event is within the bounds of the object cloning the event.

Usage example:

local within = event:isWithinArea( 0, 0, self.width, self.height )

for i = #children, 1, -1 do
    children[i]:handle( event:clone( children[i].x, children[i].y, within ) )
end

Clone this wiki locally