Behaviours

trubblegum edited this page Mar 27, 2012 · 3 revisions

The following behaviours may be set for any element.

See Elements for reserved behaviours.

When overriding a reserved behaviour, use this.Gspot[this.type].behaviour(this) to retain default functionality, where behaviour is the behaviour being overridden.

element.update = function(this, dt)
Calls element:update(dt) every update, or as specified by element.updateinterval
dt is passed along by the call to Gspot:update(dt)
element.enter = function(this)
Calls element:enter() when the mouse enters the bounds of element.
element.leave = function(this)
Calls element:leave() when the mouse leaves the bounds of element.
element.click = function(this, x, y, button)
Calls element:click() when the element is clicked with the left mouse button.
x, y, button passed along by the call to Gspot:mousepress(x, y, button)
element.rclick = function(this)
As above, but applies to the right mouse button.
element.wheelup = function(this, x, y, button)
Calls element:wheelup(x, y, button) when the mousewheel is scrolled up while over this element.
element.wheeldown = function(this, x, y, button)
Calls element:wheeldown(x, y, button) when the mousewheel is scrolled down while over this element.
element.drag = true
Allows this element to be dragged with the mouse, and calls element:drop(bucket) when released.
Gspot.drag will be a reference to the element while it is being dragged.
element.rdrag = true(this)
As above, but applies to the right mouse button.
element.drag = function(this)
As element.drag = true, and element:drag() will be called every update until released.
element.rdrag = function(this)
As above, but applies to the right mouse button.
element.drop = function(this, bucket)
Calls element:drop(bucket) when this element is dropped.
bucket is the topmost element under this element, or false.
element.rdrop = function(this, bucket)
As above, but applies to the right mouse button.
element.catch = function(this, ball)
Calls element:catch(ball) when an element is dropped onto this element.
ball is the element being dropped.
element.rcatch = function(this, ball)
As above, but applies to the right mouse button.
element.keypress = function(this, key, code)
Calls element:keypress(key, code) when a key is pressed while this element has focus.
Use Gspot:setfocus(this)Gspot:unfocus() to set and clear focus, and Gspot.focus to get the element which has focus, or false.
key, code passed along by the call to Gspot:keypress(key, code)