win.buttonWindow - WIN

Class buttonWindow
Inherits from window.

The buttonWindow class provides a string label with a height of 1 and width of the length of the label. Its colors are initialized from the theme but may be customized after creation. A btn_click event is sent to the parent with a parameter of this button window object when it is left clicked/touched/enter key pressed while active.

To create a buttonWindow use it's new method:
local btn = win.buttonWindow:new (parent, id, x, y, label)


Properties

btn__colors table Button color table.
btn__colors.text number Text color.
btn__colors.back number Blurred background color.
btn__colors.focus number Focused background color.

Methods

See also API Reference, WIN.

win.buttonWindow:constructor

btn buttonWindow:constructor (parent, id, x, y, label)

Constructs and returns the instantiated button window.

Parameters
parent window Parent window, typically a frame.
id number Numeric id value for button window.
x number Parent relative x position.
y number Parent relative y position.
label string Button label.

Returns
btn buttonWindow The instantiated button window.

Remarks


top


win.buttonWindow:draw

buttonWindow:draw (gdi, bounds)

Draws the button control.

Parameters
gdi GDI GDI object to use for drawing.
bounds rect Invalidated area of the window.

Returns
none


Remarks
See window:draw.


top


win.buttonWindow:on_blur

result buttonWindow:on_blur (focused)

Sets blurred background color.

Parameters
focused window The window gaining focus, it may be nil.

Returns
result boolean Always false.

Remarks
See window:on_blur.


top


win.buttonWindow:on_focus

result buttonWindow:on_focus (blurred)

Sets focused background color.

Parameters
blurred window The window losing focus, it may be nil.

Returns
result boolean Always false.

Remarks
See window:on_focus.


top


win.buttonWindow:on_key

result buttonWindow:on_key (key, ctrl, alt, shift)

Calls on_left_click handler on enter key.

Parameters
key number Key code.
ctrl boolean True if control key is depressed.
alt boolean True if alternate key is depressed.
shift boolean True if shift key is depressed.

Returns
result boolean Always true.

Remarks
See window:on_key.


top


win.buttonWindow:on_left_click

result buttonWindow:on_left_click (x, y, count)

Calls the base implementation and sends a btn_click event to the parent window with this button object as the first parameter.

Parameters
x number Window relative x position.
y number Window relative y position.
count
number The number of times this same position was repeatedly clicked, with each successive click within the double_click_time.

Returns
result boolean Result from base call.

Remarks
See window:on_left_click.


top


win.buttonWindow:on_touch

result buttonWindow:on_touch (x, y)

Calls the base implementation and sends a btn_click event to the parent window with this button object as the first parameter.

Parameters
x number Window relative x position.
y number Window relative y position.

Returns
result boolean Result from base call.

Remarks
See window:on_touch.


top


win.buttonWindow:set_colors

buttonWindow:set_colors (text, background, focus)

Sets the colos for the button window object.

Parameters
text number Text color.
background number Blurred background color.
focus number Focused background color.

Returns
none


Remarks
The window is invalidated.


top


See also API Reference, WIN.