Show TOC Welcome to the QLIB 1.0 Online Reference
QLIB 

QButton


Extends:QControl
Requires:
<script language="JavaScript" src="js/qlib/control.js"></script>
<script language="JavaScript" src="js/qlib/buttonres.js"></script>
<script language="JavaScript" src="js/qlib/button.js"></script>
Show Demo

Description

QLIB button is a flexible control that can be customized to serve either as a normal clickable button or as a checkbox. Additionally to these common control types QLIB introduces a web-button and a signal. Button control may have an optinal tooltip.

See Also

QButtonRes, UI Controls

Constructor

QButton(parent, name, res, tooltipopt)
Creates a customizable button from the resource provided. If the button is created as a child control, valid parent object must be specified. If the button object is assigned to global variable, parent should be null. The name should be the same as the name of variable or property that has been assigned by newly created object.
Parameters
parent - Parent control (if any, null otherwise).
name - The object reference name.
res - Button resource (see QButtonRes for details).
tooltip - Optional tooltip text.

Properties

PropertyAccessDescription
resRRefers to the resource object used to create the button.
valueRReturns current button position as follows: 1 - pressed; 0 - released.
enabledRIndicates whether the button is in "enabled" state. When disabled, a button doesn't react neither on hits nor on calls of set method.
 
Properties inherited from QControl
nameRName of the control. Serves as a direct reference to this object when evaluated.
idRAlphanumerical unique identifier of the control.
parentRReference to the parent control (if any, null otherwise).
tagR / WCan refer any value or object, tag is always passed to all event handlers as the last parameter.
windowRThis property is a reference to JavaScript window object in which the control exists.
documentRRefers to document object in which the corresponding HTML elements exist. Normally all elements of a DOM2 compatible browser are children of the top document object. If the control creates new document scope (i.e. printing tags like <IFRAME>, <LAYER>), it should assign this document to this property.

Methods

set(value)
Forces the button position to change to desirable state. This method has no effect when button is disabled.
Parameters
value - Desirable state as follows: 0 - released, 1 - pressed.
Returns
Always returns true value.
enable(state)
Enables or disables the button control.
Parameters
state - If true, this component is enabled; otherwise this component is disabled.
update()
Updates the component on the screen according to its current state.

Event Handlers

onClick(value, tag)
Is raised by the button when user clicks on the button. Button doesn't raise any events when disabled.
Parameters
value - Presents the button state after it reacted on the event.
tag - Tag is commonly used to parameterize the event handler. Each control can be optionally assigned by a tag.
Returns
The return value is ignored.

Class Constants

ConstantDescription
QButton.NORMALCreates a normal button.
QButton.CHECKBOXCreates a double-state toggle, known as a checkbox.
QButton.WEBCreates a web-button. Unlike normal button, a web-button changes its state when mouse pointer moves over it.
QButton.SIGNALCreates a signal icon. Unlike buttons, a signal doesn't react on user activity. This button style is useful when you want to have an icon that changes its appearance on application internal events.

CSS Class Selectors

CSS ClassDescriptionExample (defined in a CSS file)
IMG.qbuttonDefines style properties of a button's IMG element.IMG.qbutton { margin: 10px } /* creates 10px spacing around a button. */