Class tsKeyboard

Author
Giovanni Capalbo <gcapalbo@users.sourceforge.net>
License
This source file is subject to the LGPL license, which is available online at this address: http://www.gnu.org/copyleft/lesser.html

This class used to create the default keyboards used by the toolkit. It may also be used to create additional custom keyboards.



Attribute Summary


NameDescription
nameA short name to identify the keyboard as an option on other keyboards.
idA unique id for this tsKeyboard instance, which is set upon instantiation.
stateButtonsAn array of HTMLElements representing the buttons found in the topmost row of the keyboard.
keyboardThe HTMLElement that is the visual representation of this tsKeyboard.
boundTrue if this tsKeyboard's keyboard element has already been appended to the body element, false if not.
booleanTrue if this tsKeyboard's keyboard element is currently displayed on the screen, false if not.
instancesAn Array that stores all tsKeyboard instances, where each index is a tsKeyboard id and each value is the corresponding reference to the tsKeyboard object with that id.
namesAn Array that stores all tsKeyboard names, where each index is a tsKeyboard id and each value is the corresponding name of the tsKeyboard object with that id.
currentKeyboardIdThe id of the currently selected tsKeyboard.
lastXThe last x-coordinate (in relation to the upper-left corner of the browser) of the currently selected keyboard before it was hidden.
lastYThe last y-coordinate (in relation to the upper-left corner of the browser) of the currently selected keyboard before it was hidden.


Constructor Summary


Signature
tsKeyboard(name)


Method Summary


Return TypeSignature
voidaddDefaultNumberPad(name)
numberaddInstance(obj, name)
voidaddLine(chars, mLeft)
HTMLElementcreateAcuteAccentKey()
HTMLElementcreateBackspace()
HTMLElementcreateButton(text, value)
HTMLElementcreateCaps()
HTMLElementcreateCircumflexKey()
HTMLElementcreateGraveAccentKey()
HTMLElementcreateLine(chars)
HTMLElementcreateSpace()
HTMLElementcreateSpecialKeyByFunction(text, fcn)
HTMLElementcreateSpecialKeyByLetters(text, lowercase, uppercase)
HTMLElementcreateTab()
HTMLElementcreateTildeKey()
HTMLElementcreateUnicodeKey(code)
tsKeyboardgetInstance(id)
tsKeyboardgetInstanceByName(name)
stringgetName(id)
voidhide()
voidrefreshStateButtons(kbId)
voidreplaceKeyboard(kbId)
voidshow()


Attribute Details

name

Type
string
Description
A short name to identify the keyboard as an option on other keyboards.
Access
public



id

Type
number
Description
A unique id for this tsKeyboard instance, which is set upon instantiation.
Access
public



stateButtons

Type
Array
Description
An array of HTMLElements representing the buttons found in the topmost row of the keyboard.
Access
public



keyboard

Type
HTMLElement
Description
The HTMLElement that is the visual representation of this tsKeyboard.
Access
public



bound

Type
boolean
Description
True if this tsKeyboard's keyboard element has already been appended to the body element, false if not.
Access
public



boolean

Type
shown
Description
True if this tsKeyboard's keyboard element is currently displayed on the screen, false if not.
Access
public



instances

NOTE: This attribute is static, so it is referenced as tsKeyboard.instances
Type
Array
Description
An Array that stores all tsKeyboard instances, where each index is a tsKeyboard id and each value is the corresponding reference to the tsKeyboard object with that id.
Access
public



names

NOTE: This attribute is static, so it is referenced as tsKeyboard.names
Type
Array
Description
An Array that stores all tsKeyboard names, where each index is a tsKeyboard id and each value is the corresponding name of the tsKeyboard object with that id.
Access
public



currentKeyboardId

NOTE: This attribute is static, so it is referenced as tsKeyboard.currentKeyboardId
Type
number
Description
The id of the currently selected tsKeyboard.
Access
public



lastX

NOTE: This attribute is static, so it is referenced as tsKeyboard.lastX
Type
number
Description
The last x-coordinate (in relation to the upper-left corner of the browser) of the currently selected keyboard before it was hidden.
Access
public



lastY

NOTE: This attribute is static, so it is referenced as tsKeyboard.lastY
Type
number
Description
The last y-coordinate (in relation to the upper-left corner of the browser) of the currently selected keyboard before it was hidden.
Access
public


Constructor Details

tsKeyboard

Description
Constructs a tsKeyboard object. By constructing a tsKeyboard object, the newly created object automatically becomes an option on the line of state buttons on all other tsKeyboards' keyboard elements.
Parameters
TypeNameDescription
stringnameA short name to identify the keyboard as an option on other keyboards, which should be unique.


Method Details

addDefaultNumberPad

Description
Creates and adds the default number pad to the list of available keyboards.
Parameters
TypeNameDescription
stringnamethe name to assign to the keyboard
Return
void
Access
public



addInstance

NOTE: This method is static, so it is referenced as tsKeyboard.addInstance
Description
Stores information about a tsKeyboard object into the static tsKeyboard.instances and tsKeyboard.names variables of the tsKeyboard class. This function is automatically called upon instantiating a tsKeyboard object.
Parameters
TypeNameDescription
tsKeyboardobjA reference to the tsKeyboard object to store.
stringnameThe name of the tsKeyboard to store.
Return
number; The id of the tsKeyboard added.
Access
public



addLine

Description
Adds the given line of characters to this tsKeyboard's keyboard element as a new line of buttons, with a button for each character.
Parameters
TypeNameDescription
stringcharsA string of characters to explode into a line of buttons, with one button per character.
numbermLeftThe left margin of the entire line of buttons, as a number of pixels. If unsure, set to 0.
Return
void
Access
public



createAcuteAccentKey

NOTE: This method is static, so it is referenced as tsKeyboard.createAcuteAccentKey
Description
Creates an acute accent key, which adds an acute accent to the last character of the currentInputTarget.
Parameters
(none)
Return
HTMLElement; A HTMLElement representing the newly created button.
Access
public



createBackspace

NOTE: This method is static, so it is referenced as tsKeyboard.createBackspace
Description
Creates a Backspace button, which allows deleting characters from the end of the current input target.
Parameters
(none)
Return
HTMLElement; An HTMLElement representing the newly created Backspace button.
Access
public



createButton

NOTE: This method is static, so it is referenced as tsKeyboard.createButton
Description
Creates a keyboard button
Parameters
TypeNameDescription
stringtextThe text to display on the button.
mixedvalueThe character to "press" when clicked. Can be a One-character string, the numerical code of a character, or null to not press any character when clicked upon.
Return
HTMLElement; A HTMLElement representing the newly created button.
Access
public



createCaps

NOTE: This method is static, so it is referenced as tsKeyboard.createCaps
Description
Creates a Caps Lock button, which allows switching between all-uppercase and all-lowercase output.
Parameters
(none)
Return
HTMLElement; An HTMLElement representing the newly created Caps Lock button.
Access
public



createCircumflexKey

NOTE: This method is static, so it is referenced as tsKeyboard.createCircumflexKey
Description
Creates a circumflex key, which adds a circumflex to the last character of the currentInputTarget.
Parameters
(none)
Return
HTMLElement; A HTMLElement representing the newly created button.
Access
public



createGraveAccentKey

NOTE: This method is static, so it is referenced as tsKeyboard.createGraveAccentKey
Description
Creates a grave accent key, which adds a grave to the last character of the currentInputTarget.
Parameters
(none)
Return
HTMLElement; A HTMLElement representing the newly created button.
Access
public



createLine

NOTE: This method is static, so it is referenced as tsKeyboard.createLine
Description
Creates a line of keyboard buttons, attaching the appropriate "click" events to them.
Parameters
TypeNameDescription
stringcharsA string representing the characters to add. A button will be added for each character.
Return
HTMLElement; A HTMLElement representing the newly created line of buttons.
Access
public



createSpace

NOTE: This method is static, so it is referenced as tsKeyboard.createSpace
Description
Creates a Space button, which allows adding spaces to the current input target.
Parameters
(none)
Return
HTMLElement; An HTMLElement representing the newly created Space button.
Access
public



createSpecialKeyByFunction

NOTE: This method is static, so it is referenced as tsKeyboard.createSpecialKeyByFunction
Description
Creates a special key for a keyboard, specifying what function to execute when clicked upon.
Parameters
TypeNameDescription
stringtextThe text to display on the button.
functionfcnThe function to execute in response to the click event.
Return
HTMLElement; A HTMLElement representing the newly created button.
Access
public



createSpecialKeyByLetters

NOTE: This method is static, so it is referenced as tsKeyboard.createSpecialKeyByLetters
Description
Creates a special key for a keyboard, specifying the characters to press on caps and lowercase.
Parameters
TypeNameDescription
stringtextThe text to display on the button.
stringlowercaseThe character to "press" when clicked and Caps is off.
stringuppercaseThe character to "press" when clicked and Caps is off.
Return
HTMLElement; A HTMLElement representing the newly created button.
Access
public



createTab

NOTE: This method is static, so it is referenced as tsKeyboard.createTab
Description
Creates a Tab button, which allows switching focus between the text/password inputs on the page.
Parameters
(none)
Return
HTMLElement; An HTMLElement representing the newly created Tab button.
Access
public



createTildeKey

NOTE: This method is static, so it is referenced as tsKeyboard.createTildeKey
Description
Creates a tilde key, which adds a tilde to the last character of the currentInputTarget if it is an a or n.
Parameters
(none)
Return
HTMLElement; A HTMLElement representing the newly created button.
Access
public



createUnicodeKey

NOTE: This method is static, so it is referenced as tsKeyboard.createUnicodeKey
Description
Creates a key for a keyboard with the given unicode code. Note: The returned button is case-independent of the tsUI.caps state.
Parameters
TypeNameDescription
numbercodeThe unicode code.
Return
HTMLElement; A HTMLElement representing the newly created button.
Access
public



getInstance

NOTE: This method is static, so it is referenced as tsKeyboard.getInstance
Description
Retrieves a reference to a tsKeyboard object by its id.
Parameters
TypeNameDescription
numberidThe id of the tsKeyboard object to retrieve.
Return
tsKeyboard; A reference to the tsKeyboard object.
Access
public



getInstanceByName

NOTE: This method is static, so it is referenced as tsKeyboard.getInstanceByName
Description
Retrieves a reference to a tsKeyboard object by its name.
Parameters
TypeNameDescription
stringnameThe name of the tsKeyboard object to retrieve.
Return
tsKeyboard; A reference to the tsKeyboard object, or null if not found.
Access
public



getName

NOTE: This method is static, so it is referenced as tsKeyboard.getName
Description
Retrieves the name of the tsKeyboard with the given id.
Parameters
TypeNameDescription
numberidThe id of the tsKeyboard object whose name to retrieve.
Return
string; The name of the tsKeyboard object.
Access
public



hide

Description
Hides this tsKeyboard's keyboard element.
Parameters
(none)
Return
void
Access
public



refreshStateButtons

NOTE: This method is static, so it is referenced as tsKeyboard.refreshStateButtons
Description
Adds or replaces the first line of keyboard buttons, which control the state of each keyboard (move, hide, switch keyboards). This function is called every time a keyboard is displayed to ensure that any changes to the state buttons are reflected
Parameters
TypeNameDescription
numberkbIdThe id of the tsKeyboard object whose state buttons to refresh.
Return
void
Access
public



replaceKeyboard

NOTE: This method is static, so it is referenced as tsKeyboard.replaceKeyboard
Description
Replaces the currently selected tsKeyboard with the one given, and shows the new one.
Parameters
TypeNameDescription
numberkbIdThe id of the tsKeyboard to replace the current one with.
Return
void
Access
public



show

Description
Shows this tsKeyboard's keyboard element, making sure that it is updated with any changes that have occurred since it was last displayed.
Parameters
(none)
Return
void
Access
public