Defining multiple input modes

An input mode is a set of input bindings that get mapped (and unmapped) together. So far, the example apps have used only the default input mode, which is created and activated automatically.

To define a custom input mode, simply instantiate a subclass of InputMode and attach it using the state manager. Acorus allows an application to attach any number of input modes, but only one of them (at most) can be active at a time.

To activate or deactivate an input mode, invoke mode.setEnabled()

ActionApplication invokes the onInputModeChange() callback each time the active input mode changes.

In an AcorusDemo displaying detailed help, mode changes are automatically reflected in the help node.

TestTwoModes

TestTwoModes is an example application that modifies HelloSimpleApplication by adding a custom input mode named "edit".

The input bindings depend on which mode is active:

  • Initially, the default input mode is active, with FlyByCamera enabled for camera movement.

  • Pressing Enter or Tab switches the app into "edit" mode, allowing the user to enter a line of text.

  • Pressing Enter or Tab again returns the app to the default mode.

TestCursors

Each input mode can specify how and whether the cursor (mouse pointer) is displayed. In a multi-mode application, giving each mode a distinct cursor image helps remind the user which mode is active.

TestCursors is an example application that modifies HelloSimpleApplication by adding a 3 custom input modes, each with its own cursor image.

  • Initially, the default input mode is active, and the cursor is a diagonal white arrow.

  • Pressing F2 activates "dialog" mode, in which the cursor is a diagonal yellow arrow.

  • Pressing F3 activates "green" mode, in which the cursor is a diagonal green arrow.

  • Pressing F4 activates "menu" mode, in which the cursor is a horizontal magenta arrow.

  • Pressing F1 returns the app to the default input mode.

Summary

  • Applications can define any number of input modes.

  • Only one input mode can be active at a time.

  • Use setEnabled() to activate or deactivate an input mode.

  • Each input mode can have its own cursor style.