Component - xkp/Doc GitHub Wiki

Overview

The component object represent the base class for all components, it is non instantiable.

Properties

id: indicates the name of the component

x, y: the position of the component, relative to its parent

width, height: dimensions

visible: whether the component is visible or not

alpha: opacity, where 0 is completely transparent and 100 completely opaque

rotation: in degrees

Methods

position(x, y): Positions the component

size(w, h): Resizes the component

rect(x, y, w, h): Positions and resize the component

hide(): Hides the component

show(): Shows the component when hidden

invalidate(): Instructs the component to be redrawn

Events

moved: Fires when the component's position changes

resized: Fires when the component's size changes

keydown(keycode): Fires when a key is pressed down

keyup(keycode): Fires when a key is released

keypress(keycode): Fires when a key is pressed (down + up)

drag(x, y): Fires when a component is being dragged

dragend(x, y): Fires when a component stops being dragged

mousein(): Fires when the mouse first enters a component

mouseout(): Fires when the mouse first leaves a component

mousemove(): Fires when the mouse moves over a component

mousedown(x, y): Fires when the mouse is pressed over a component

mouseup(x, y): Fires when the mouse is released over a component

click(): Fires when the mouse is clicked (down + up) over a component