new ButtonBinding(viewer, buttonsIn, downopt, nullable, upopt, nullable, holdopt, nullable, buttonsOutopt, nullable, contextopt, nameopt)
Button binding object that handles buttons event for a list of buttons.
To use a button binding, you have to add it to a FORGE.Gamepad.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
viewer |
FORGE.Viewer | the viewer referemce. | |
buttonsIn |
Array.<number> | number | The button code (or array) associated to this binding. | |
down |
function | string | Array.<string> |
<optional> <nullable> |
The callback function that will be called on a button down event. |
up |
function | string | Array.<string> |
<optional> <nullable> |
The callback function that will be called on a button release event. |
hold |
function | string | Array.<string> |
<optional> <nullable> |
The callback function that will be called if a button is hold. |
buttonsOut |
Array.<number> | number |
<optional> <nullable> |
The button code (or array) that will be rejected if the button is down. |
context |
Object |
<optional> |
The context in which you want your "down", "hold" & up callbacks to execute. |
name |
string |
<optional> |
The name of the binding, can be use as an identifier. |
- Source:
Extends
Members
(readonly) alive :boolean
Get the alive flag value of the object.
Type:
- boolean
- Inherited From:
- Source:
(readonly) className :string
Get the class name of the object.
Type:
- string
- Inherited From:
- Source:
data :*
Get and set any custom data you want to associate to this object.
Type:
- *
- Inherited From:
- Source:
debug :boolean
Get and set the debug flag.
Type:
- boolean
- Inherited From:
- Source:
(readonly) downComplete :boolean
Gets the downComplete value.
Type:
- boolean
- Source:
(readonly) downCount :number
Gets the down count value.
Type:
- number
- Source:
(readonly) hasToWaitToHold :boolean
Gets the hasToWaitToHold value.
Type:
- boolean
- Source:
(readonly) holdCount :number
Gets the hold count value.
Type:
- number
- Source:
(readonly) name :string
Gets the name of this BaseBinding.
Type:
- string
- Inherited From:
- Source:
(readonly) onDestroy :FORGE.EventDispatcher
Get the onDestroy FORGE.EventDispatcher, this event is emitted at the end of the destroy sequence.
Type:
- Inherited From:
- Source:
(readonly) pressed :boolean
Gets the pressed status of this ButtonBinding.
Type:
- boolean
- Source:
(readonly) tags :Array
Get the tags associated to this object.
Type:
- Array
- Inherited From:
- Source:
(readonly) type :string
Gets the type of this BaseBinding.
Type:
- string
- Inherited From:
- Source:
(readonly) uid :string
Get the uid of the object.
Type:
- string
- Inherited From:
- Source:
(readonly) upCount :number
Gets the up count value.
Type:
- number
- Source:
warning :boolean
Get and set the warning flag.
Type:
- boolean
- Inherited From:
- Source:
Methods
_boot()
Boot sequence
- Source:
destroy()
Destroy sequence.
- Overrides:
- Source:
down(value)
This method is called by the input associated when a button is down. This triggers the
down callback associated to this binding and increases the downCount value.
Parameters:
Name | Type | Description |
---|---|---|
value |
number | the value of the button |
- Source:
hasButtonIn(button) → {boolean}
Know if a button is associated to this binding by being in.
Parameters:
Name | Type | Description |
---|---|---|
button |
number | the code of the button to check |
- Source:
Returns:
true if associated, else false
- Type
- boolean
hasButtonOut(button) → {boolean}
Know if a button is associated to this binding by being out.
Parameters:
Name | Type | Description |
---|---|---|
button |
number | the code of the button to check |
- Source:
Returns:
true if associated, else false
- Type
- boolean
hold()
This method is called by the input associated when a button is hold. This triggers the
hold callback associated to this binding and increases the holdCount value.
- Source:
log(value)
Basic log method, log a string in the console if debug is enabled.
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value you want to log in the console. |
- Inherited From:
- Source:
up(value)
This method is called by the input associated when a button is up. This triggers the
up callback associated to this binding and increases the upCount value.
Parameters:
Name | Type | Description |
---|---|---|
value |
number | the value of the button |
- Source:
waitToHold() → {function}
This method has to be called by the user down callback to specify that the button down have to
wait to be considered as holded.
This gives in return a callback to set the down as complete.
This gives in return a callback to set the down as complete.
- Source:
Returns:
Returns a callback function that the user have to call to set the down as complete to allow hold.
- Type
- function
warn(valuenullable)
Basic warn method, log a warn string in the console if warning is enabled.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
value |
string | Object |
<nullable> |
The value you want to warn in the console. |
- Inherited From:
- Source: