MouseControls
Mouse controls
Constructor Summary
Public Constructor | ||
public |
constructor(stage: Stage, params: Object) |
Member Summary
Public Members | ||
public |
|
|
public |
Flag to disable all actions |
|
public |
|
|
public |
|
Method Summary
Public Methods | ||
public |
add(triggerStr: TriggerString, callback: function(stage: Stage, ...args: Any)): undefined Add a new mouse action triggered by an event, key and button combination. |
|
public |
Remove all mouse actions |
|
public |
Set mouse action preset |
|
public |
remove(triggerStr: TriggerString, callback: Function): undefined Remove a mouse action. |
|
public |
run() |
Public Constructors
Public Methods
public add(triggerStr: TriggerString, callback: function(stage: Stage, ...args: Any)): undefined source
Add a new mouse action triggered by an event, key and button combination. The MouseActions class provides a number of static methods for use as callback functions.
Params:
Name | Type | Attribute | Description |
triggerStr | TriggerString | the trigger for the action |
|
callback | function(stage: Stage, ...args: Any) | the callback function for the action |
Example:
// change ambient light intensity on mouse scroll
// while the ctrl and shift keys are pressed
stage.mouseControls.add( "scroll-ctrl+shift", function( stage, delta ){
var ai = stage.getParameters().ambientIntensity;
stage.setParameters( { ambientIntensity: Math.max( 0, ai + delta / 50 ) } );
} );
// Call the MouseActions.zoomDrag method on mouse drag events
// with left and right mouse buttons simultaneous
stage.mouseControls.add( "drag-left+right", MouseActions.zoomDrag );
public preset(name: String): undefined source
Set mouse action preset
Params:
Name | Type | Attribute | Description |
name | String | one of "default", "pymol", "coot" |
public remove(triggerStr: TriggerString, callback: Function): undefined source
Remove a mouse action. The trigger string can contain an asterix (*) as a wildcard for any key or mouse button. When the callback function is given, only actions that call that function are removed.
Params:
Name | Type | Attribute | Description |
triggerStr | TriggerString | the trigger for the action |
|
callback | Function |
|
the callback function for the action |
Example:
// remove actions triggered solely by a scroll event
stage.mouseControls.remove( "scroll" );
// remove actions triggered by a scroll event, including
// those requiring a key pressed or mouse button used
stage.mouseControls.remove( "scroll-*" );
// remove actions triggered by a scroll event
// while the shift key is pressed
stage.mouseControls.remove( "scroll-shift" );