Class tsKeyboard
Giovanni Capalbo <gcapalbo@users.sourceforge.net>
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
Name | Description |
name | A short name to identify the keyboard as an option on other keyboards. |
id | A unique id for this tsKeyboard instance, which is set upon instantiation. |
stateButtons | An array of HTMLElements representing the buttons found in the topmost row of the keyboard. |
keyboard | The HTMLElement that is the visual representation of this tsKeyboard. |
bound | True if this tsKeyboard's keyboard element has already been appended to the body element, false if not. |
boolean | True if this tsKeyboard's keyboard element is currently displayed on the screen, false if not. |
instances | 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. |
names | 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. |
currentKeyboardId | The id of the currently selected tsKeyboard. |
lastX | The last x-coordinate (in relation to the upper-left corner of the browser) of the currently selected keyboard before it was hidden. |
lastY | The last y-coordinate (in relation to the upper-left corner of the browser) of the currently selected keyboard before it was hidden. |
Constructor Summary
Method Summary
Attribute Details
name
string
A short name to identify the keyboard as an option on other keyboards.
public
id
number
A unique id for this tsKeyboard instance, which is set upon instantiation.
public
Array
An array of HTMLElements representing the buttons found in the topmost row of the keyboard.
public
keyboard
HTMLElement
The HTMLElement that is the visual representation of this tsKeyboard.
public
bound
boolean
True if this tsKeyboard's keyboard element has already been appended to the body element, false if not.
public
boolean
shown
True if this tsKeyboard's keyboard element is currently displayed on the screen, false if not.
public
instances
NOTE: This attribute is static, so it is referenced as tsKeyboard.instances
Array
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.
public
names
NOTE: This attribute is static, so it is referenced as tsKeyboard.names
Array
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.
public
currentKeyboardId
NOTE: This attribute is static, so it is referenced as tsKeyboard.currentKeyboardId
number
The id of the currently selected tsKeyboard.
public
lastX
NOTE: This attribute is static, so it is referenced as tsKeyboard.lastX
number
The last x-coordinate (in relation to the upper-left corner of the browser) of the currently selected keyboard before it was hidden.
public
lastY
NOTE: This attribute is static, so it is referenced as tsKeyboard.lastY
number
The last y-coordinate (in relation to the upper-left corner of the browser) of the currently selected keyboard before it was hidden.
public
Constructor Details
tsKeyboard
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.
Type | Name | Description |
string | name | A short name to identify the keyboard as an option on other keyboards, which should be unique. |
Method Details
addDefaultNumberPad
Creates and adds the default number pad to the list of available keyboards.
Type | Name | Description |
string | name | the name to assign to the keyboard |
void
public
addInstance
NOTE: This method is static, so it is referenced as tsKeyboard.addInstance
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.
Type | Name | Description |
tsKeyboard | obj | A reference to the tsKeyboard object to store. |
string | name | The name of the tsKeyboard to store. |
number; The id of the tsKeyboard added.
public
addLine
Adds the given line of characters to this tsKeyboard's keyboard element as a new line of buttons, with a button for each character.
Type | Name | Description |
string | chars | A string of characters to explode into a line of buttons, with one button per character. |
number | mLeft | The left margin of the entire line of buttons, as a number of pixels. If unsure, set to 0. |
void
public
createAcuteAccentKey
NOTE: This method is static, so it is referenced as tsKeyboard.createAcuteAccentKey
Creates an acute accent key, which adds an acute accent to the last character of the currentInputTarget.
(none)
HTMLElement; A HTMLElement representing the newly created button.
public
createBackspace
NOTE: This method is static, so it is referenced as tsKeyboard.createBackspace
Creates a Backspace button, which allows deleting characters from the end of the current input target.
(none)
HTMLElement; An HTMLElement representing the newly created Backspace button.
public
NOTE: This method is static, so it is referenced as tsKeyboard.createButton
Creates a keyboard button
Type | Name | Description |
string | text | The text to display on the button. |
mixed | value | The 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. |
HTMLElement; A HTMLElement representing the newly created button.
public
createCaps
NOTE: This method is static, so it is referenced as tsKeyboard.createCaps
Creates a Caps Lock button, which allows switching between all-uppercase and all-lowercase output.
(none)
HTMLElement; An HTMLElement representing the newly created Caps Lock button.
public
createCircumflexKey
NOTE: This method is static, so it is referenced as tsKeyboard.createCircumflexKey
Creates a circumflex key, which adds a circumflex to the last character of the currentInputTarget.
(none)
HTMLElement; A HTMLElement representing the newly created button.
public
createGraveAccentKey
NOTE: This method is static, so it is referenced as tsKeyboard.createGraveAccentKey
Creates a grave accent key, which adds a grave to the last character of the currentInputTarget.
(none)
HTMLElement; A HTMLElement representing the newly created button.
public
createLine
NOTE: This method is static, so it is referenced as tsKeyboard.createLine
Creates a line of keyboard buttons, attaching the appropriate "click" events to them.
Type | Name | Description |
string | chars | A string representing the characters to add. A button will be added for each character. |
HTMLElement; A HTMLElement representing the newly created line of buttons.
public
createSpace
NOTE: This method is static, so it is referenced as tsKeyboard.createSpace
Creates a Space button, which allows adding spaces to the current input target.
(none)
HTMLElement; An HTMLElement representing the newly created Space button.
public
createSpecialKeyByFunction
NOTE: This method is static, so it is referenced as tsKeyboard.createSpecialKeyByFunction
Creates a special key for a keyboard, specifying what function to execute when clicked upon.
Type | Name | Description |
string | text | The text to display on the button. |
function | fcn | The function to execute in response to the click event. |
HTMLElement; A HTMLElement representing the newly created button.
public
createSpecialKeyByLetters
NOTE: This method is static, so it is referenced as tsKeyboard.createSpecialKeyByLetters
Creates a special key for a keyboard, specifying the characters to press on caps and lowercase.
Type | Name | Description |
string | text | The text to display on the button. |
string | lowercase | The character to "press" when clicked and Caps is off. |
string | uppercase | The character to "press" when clicked and Caps is off. |
HTMLElement; A HTMLElement representing the newly created button.
public
createTab
NOTE: This method is static, so it is referenced as tsKeyboard.createTab
Creates a Tab button, which allows switching focus between the text/password inputs on the page.
(none)
HTMLElement; An HTMLElement representing the newly created Tab button.
public
createTildeKey
NOTE: This method is static, so it is referenced as tsKeyboard.createTildeKey
Creates a tilde key, which adds a tilde to the last character of the currentInputTarget if it is an a or n.
(none)
HTMLElement; A HTMLElement representing the newly created button.
public
createUnicodeKey
NOTE: This method is static, so it is referenced as tsKeyboard.createUnicodeKey
Creates a key for a keyboard with the given unicode code. Note: The returned button is case-independent of the tsUI.caps state.
Type | Name | Description |
number | code | The unicode code. |
HTMLElement; A HTMLElement representing the newly created button.
public
getInstance
NOTE: This method is static, so it is referenced as tsKeyboard.getInstance
Retrieves a reference to a tsKeyboard object by its id.
Type | Name | Description |
number | id | The id of the tsKeyboard object to retrieve. |
tsKeyboard; A reference to the tsKeyboard object.
public
getInstanceByName
NOTE: This method is static, so it is referenced as tsKeyboard.getInstanceByName
Retrieves a reference to a tsKeyboard object by its name.
Type | Name | Description |
string | name | The name of the tsKeyboard object to retrieve. |
tsKeyboard; A reference to the tsKeyboard object, or null if not found.
public
getName
NOTE: This method is static, so it is referenced as tsKeyboard.getName
Retrieves the name of the tsKeyboard with the given id.
Type | Name | Description |
number | id | The id of the tsKeyboard object whose name to retrieve. |
string; The name of the tsKeyboard object.
public
hide
Hides this tsKeyboard's keyboard element.
(none)
void
public
NOTE: This method is static, so it is referenced as tsKeyboard.refreshStateButtons
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
Type | Name | Description |
number | kbId | The id of the tsKeyboard object whose state buttons to refresh. |
void
public
replaceKeyboard
NOTE: This method is static, so it is referenced as tsKeyboard.replaceKeyboard
Replaces the currently selected tsKeyboard with the one given, and shows the new one.
Type | Name | Description |
number | kbId | The id of the tsKeyboard to replace the current one with. |
void
public
show
Shows this tsKeyboard's keyboard element, making sure that it is updated with any changes that have occurred since it was last displayed.
(none)
void
public