Difference between revisions of "Cabal Common Library Doc Keyboard"

From Elite Wiki
m (Overview)
m (added screenID)
Line 2: Line 2:
 
This is the main class for the keyboard with its members and part of the [[Cabal_Common_Library]].
 
This is the main class for the keyboard with its members and part of the [[Cabal_Common_Library]].
  
The keyboard is fairly simple to use and requires only a worldScripts call with a few parameters. Optionally, the calling script can provide a callback which is executed when the user has finished entering characters. Everything else performed within the script.
+
The keyboard is fairly simple to use and requires only a worldScripts call with a few parameters. Optionally, the calling script can provide a callback which is executed when the user has finished entering characters. Everything else performed within the script. The keyboard itself ships 4 different modes (Alphanumeric, Alphabetic, Numeric and Hexadecimal).
  
'''Callback:'''
+
A keyboard can only be called when the player is docked! Please also note, that missionchoices are a bit tricky and may require a workaround if you are calling another mission screen with choices in the callback function.
{{CodeEx|codeex=worldScripts[this.keyboard.toCall].Cabal_Common_Keyboard_Output(this.keyboard.input);}}
 
  
The keyboard itself ships 4 different modes
+
Missionscreens in <tt>Cabal_Common_Keyboard.js</tt> are using the screenID (v1.7.1+)
 +
{{CodeEx|codeex="Cabal_Common_Keyboard"}}
  
* Alphanumeric
+
*See [[#start()|start()]]
* Alphabetic
 
* Numeric
 
* Hexadecimal
 
  
A keyboard can only be called when the player is docked!  Please also note, that missionchoices are a bit tricky and require a workaround!  This doesn’t usually affect the calling script, but if it happens (and it will happen if you are calling another mission screen with choices in the callback function) you’ll have to use the same workaround as the keyboard.
 
  
 
== Functions ==
 
== Functions ==
 
=== start() ===
 
=== start() ===
{{CodeEx|codeex=this.start = function( who, min, mode, scpic, scovl, scmod )}}
+
{{CodeEx|codeex=worldScripts.Cabal_Common_Keyboard( who, min, mode, scpic, scovl, scmod )}}
Starts the keyboard handling, creates the keyboard object and calls keyboardShow(). If ‘who’ is specified the script will callback after completing or aborting.  See keyboardChoice() for the callback.
+
Starts the keyboard handling, creates the keyboard object and calls keyboardShow(). If ‘who’ is specified the script will callback after completing or aborting.
  
 
'''Parameters:'''
 
'''Parameters:'''
Line 31: Line 27:
 
'''Returns:'''
 
'''Returns:'''
 
:;nothing
 
:;nothing
 
{{CodeEx|codeex=worldScripts.Cabal_Common_Keyboard.start(this.name,5,1);}}
 
  
 
Suffixes are :
 
Suffixes are :
Line 40: Line 34:
 
* 3 - ‘_keyboard_hex.png’
 
* 3 - ‘_keyboard_hex.png’
 
* 4 - ‘_keyboard.png’
 
* 4 - ‘_keyboard.png’
 +
 +
Example
 +
{{CodeEx|codeex=worldScripts.Cabal_Common_Keyboard.start(this.name,5,1);}}
 +
 +
* See [[#keyboardChoice()|keyboardChoice()]] for the callback.
  
  
 
=== keyboardEval() ===
 
=== keyboardEval() ===
{{CodeEx|codeex=this.keyboardEval = function( choice )}}
+
{{CodeEx|codeex=worldScripts.Cabal_Common_Keyboard.keyboardEval = function( choice )}}
 
Workaround to change the context of this!!! It simply passes the choice to keyboardChoice().
 
Workaround to change the context of this!!! It simply passes the choice to keyboardChoice().
  
Line 57: Line 56:
  
 
=== keyboardChoice() ===
 
=== keyboardChoice() ===
{{CodeEx|codeex=this.keyboardChoice = function( choice )}}
+
{{CodeEx|codeex=worldScripts.Cabal_Common_Keyboard.keyboardChoice = function( choice )}}
Evaluates the user choice. When keyboard.toCall is specified and user confirms or aborts the keyboard input.
+
Evaluates the user choice. When keyboard.toCall is specified and user confirms or aborts the keyboard input.
  
 
'''Callback:'''
 
'''Callback:'''
* ”” - String. if user aborts.
+
* '' - String. if user aborts.
 
* keyboard.input - String.  If user confirmed input.
 
* keyboard.input - String.  If user confirmed input.
  

Revision as of 16:41, 16 February 2013

Overview

This is the main class for the keyboard with its members and part of the Cabal_Common_Library.

The keyboard is fairly simple to use and requires only a worldScripts call with a few parameters. Optionally, the calling script can provide a callback which is executed when the user has finished entering characters. Everything else performed within the script. The keyboard itself ships 4 different modes (Alphanumeric, Alphabetic, Numeric and Hexadecimal).

A keyboard can only be called when the player is docked! Please also note, that missionchoices are a bit tricky and may require a workaround if you are calling another mission screen with choices in the callback function.

Missionscreens in Cabal_Common_Keyboard.js are using the screenID (v1.7.1+)

"Cabal_Common_Keyboard"


Functions

start()

worldScripts.Cabal_Common_Keyboard( who, min, mode, scpic, scovl, scmod )

Starts the keyboard handling, creates the keyboard object and calls keyboardShow(). If ‘who’ is specified the script will callback after completing or aborting.

Parameters:

who
String. The name of a worldScript which implements the keyboard callback.
min
Number. Optional - minimum length for completion, default(4).
mode
Number. Optional - 1(only alphabetical), 2(only numeric), 3(hexadecimal), default 4(alphanumeric).
scpic
String. Optional. Name for screenbackground build upon scpic + suffix. The mode defines which one will be used.
scovl
String. Optional. Filename for screenoverlay (with fileextension). Default null.
scmod
String. Optional. Role for the used model. Default ‘cabal_common_key’.

Returns:

nothing

Suffixes are :

  • 1 - ‘_keyboard_alpha.png’
  • 2 - ‘_keyboard_nums.png’
  • 3 - ‘_keyboard_hex.png’
  • 4 - ‘_keyboard.png’

Example

worldScripts.Cabal_Common_Keyboard.start(this.name,5,1);


keyboardEval()

worldScripts.Cabal_Common_Keyboard.keyboardEval = function( choice )

Workaround to change the context of this!!! It simply passes the choice to keyboardChoice().

Parameters:

choice
String. Passed parameter from Oolite.

Returns:

nothing

Calls:

worldScripts.Cabal_Common_Keyboard.keyboardChoice(choice);


keyboardChoice()

worldScripts.Cabal_Common_Keyboard.keyboardChoice = function( choice )

Evaluates the user choice. When keyboard.toCall is specified and user confirms or aborts the keyboard input.

Callback:

  • - String. if user aborts.
  • keyboard.input - String. If user confirmed input.
worldScripts[this.keyboard.toCall].Cabal_Common_Keyboard_Output(this.keyboard.input);

Parameters:

choice
String. Passed parameter from Oolite, passed through keyboardEval().

Returns:

nothing