Package | cc.cote.feathers.softkeyboard |
Class | public class SoftKeyboard |
Inheritance | SoftKeyboard ![]() |
Layout
base class.
Creating a keyboard and listening for input is very easy. All you need to do is pass the desired layout to the SoftKeyboard constructor and add an event listener:
var keyboard:SoftKeyboard = new SoftKeyboard(new QwertyEn()); keyboard.addEventListener(SoftKeyboardEvent.KEY_UP, _onKeyUp); addChild(keyboard);
It is also possible to create keyboards with multiple layouts by passing a vector of
Layout
objects to the constructor. This makes it easy to have a keyboard with
one layout for regular letters and another one for numbers and symbols, for example.
Switching between them is possible by pressing the special SWITCH_LAYOUT
key.
Layouts that have a SWITCH_LAYOUT
key generally accept as a constructor
parameter the class of the layout that the SWITCH_LAYOUT
key should instantiate
when pressed. Here is an example that will toggle between the QwertyEnSingleSwitch
and NumbersAndSymbolsSingleSwitch
layouts:
var layouts:Vector.<Layout> = new <Layout>[ new QwertyEnSingleSwitch(NumbersAndSymbolsSingleSwitch), new NumbersAndSymbolsSingleSwitch(QwertyEnSingleSwitch) ]; var keyboard:SoftKeyboard = new SoftKeyboard(layouts); addChild(keyboard);
A full, working code example is provided with the SoftKeyboard
download
package.
In order for the keyboard to display properly, you must skin it through the use of a Feathers' theme (a sample theme is provided in the download package). If you don't, a generic grey skin will be used for reference. Besides assigning skins in your theme, you should also define a TextRenderer and assign a TextFormat. For more information, see the Feathers documentation.
SoftKeyboard
requires Feathers 1.0 or newer
which itself requires the Starling framework.
See also
Property | Defined By | ||
---|---|---|---|
backgroundSkin : DisplayObject The background to use for the SoftKeyboard. | SoftKeyboard | ||
capsLock : Boolean Indicates whether the caps lock key is currently activated (true) or not (false). | SoftKeyboard | ||
layoutIndex : uint The index of the currently displayed layout from the layouts vector. | SoftKeyboard | ||
layouts : Vector.<Layout> [read-only] A vector of all Layout objects assigned to the keyboard. | SoftKeyboard | ||
padding : Number = 0 The free space between the outside of the keyboard and the keys. | SoftKeyboard |
Method | Defined By | ||
---|---|---|---|
SoftKeyboard(layouts:Object, width:Number = 320, height:Number = 160)
Creates a new SoftKeyboard object. | SoftKeyboard |
Event | Summary | Defined By | ||
---|---|---|---|---|
Dispatched when an on-screen key is pressed. | SoftKeyboard | |||
Dispatched when an on-screen key is released. | SoftKeyboard |
Constant | Defined By | ||
---|---|---|---|
VERSION : String = 1.0a rev8 Version of this SoftKeyboard library | SoftKeyboard |
backgroundSkin | property |
public var backgroundSkin:DisplayObject
The background to use for the SoftKeyboard.
capsLock | property |
capsLock:Boolean
Indicates whether the caps lock key is currently activated (true) or not (false).
public function get capsLock():Boolean
public function set capsLock(value:Boolean):void
layoutIndex | property |
layoutIndex:uint
The index of the currently displayed layout from the layouts
vector.
public function get layoutIndex():uint
public function set layoutIndex(value:uint):void
layouts | property |
layouts:Vector.<Layout>
[read-only] A vector of all Layout objects assigned to the keyboard.
public function get layouts():Vector.<Layout>
padding | property |
public var padding:Number = 0
The free space between the outside of the keyboard and the keys.
SoftKeyboard | () | Constructor |
public function SoftKeyboard(layouts:Object, width:Number = 320, height:Number = 160)
Creates a new SoftKeyboard object.
Parameterslayouts:Object — A single Layout object or a vector of Layout
objects to use with the keyboard
| |
width:Number (default = 320 ) — Full outer width of the keyboard (including any padding)
| |
height:Number (default = 160 ) — Full outer height of the keyboard (including any padding)
|
Error — First parameter must be a Layout object or a vector of Layout objects.
|
See also
cc.cote.feathers.softkeyboard.KeyEvent.keyDown | Event |
cc.cote.feathers.softkeyboard.KeyEvent
cc.cote.feathers.softkeyboard.KeyEvent.KEY_DOWN
Dispatched when an on-screen key is pressed.
TheKEY_DOWN
constant defines the value of the type
property of
a keyDown
event object.
cc.cote.feathers.softkeyboard.KeyEvent.keyUp | Event |
cc.cote.feathers.softkeyboard.KeyEvent
cc.cote.feathers.softkeyboard.KeyEvent.KEY_UP
Dispatched when an on-screen key is released. The release must be above the key that was initially pressed otherwise the event is not fired.
TheKEY_UP
constant defines the value of the type
property of a
keyUp
event object.
VERSION | Constant |
public const VERSION:String = 1.0a rev8
Version of this SoftKeyboard library