Simbody
3.6
|
This abstract class defines methods to be called when the Visualizer reports user activity back to the simulation process. Derive a concrete event listener whose methods take appropriate actions when event of interest occur. More...
Public Types | |
enum | Modifier { ShiftIsDown = 0x01, ControlIsDown = 0x02, AltIsDown = 0x04, IsSpecialKey = 0xC0 } |
These represent modifications to the character that is passed into the keyPressed() method, including whether any of Shift/Control/Alt were down and whether a special non-ASCII code is being supplied, such as is required for an arrow key. More... | |
enum | KeyCode { KeyControlC = 3, KeyBeep = 7, KeyBackspace = 8, KeyTab = 9, KeyLF = 10, KeyReturn = 13, KeyEnter = KeyReturn, KeyEsc = 27, KeyDelete = 127, KeyF1 = SpecialKeyOffset + 1, KeyF2 = SpecialKeyOffset + 2, KeyF3 = SpecialKeyOffset + 3, KeyF4 = SpecialKeyOffset + 4, KeyF5 = SpecialKeyOffset + 5, KeyF6 = SpecialKeyOffset + 6, KeyF7 = SpecialKeyOffset + 7, KeyF8 = SpecialKeyOffset + 8, KeyF9 = SpecialKeyOffset + 9, KeyF10 = SpecialKeyOffset + 10, KeyF11 = SpecialKeyOffset + 11, KeyF12 = SpecialKeyOffset + 12, KeyLeftArrow = SpecialKeyOffset + 100, KeyUpArrow = SpecialKeyOffset + 101, KeyRightArrow = SpecialKeyOffset + 102, KeyDownArrow = SpecialKeyOffset + 103, KeyPageUp = SpecialKeyOffset + 104, KeyPageDown = SpecialKeyOffset + 105, KeyHome = SpecialKeyOffset + 106, KeyEnd = SpecialKeyOffset + 107, KeyInsert = SpecialKeyOffset + 108 } |
These are the special keys that the Visualizer may report via the keyPressed() method. More... | |
Public Member Functions | |
virtual | ~InputListener () |
Destructor is virtual; be sure to override it if you need to clean up. More... | |
virtual bool | keyPressed (unsigned key, unsigned modifiers) |
This method is called when a user hits a keyboard key in the Visualizer window, unless that key is being intercepted by the Visualizer for its own purposes. More... | |
virtual bool | menuSelected (int menu, int item) |
The user has clicked one of the menu items you defined; here is the integer value you specified when you defined it. More... | |
virtual bool | sliderMoved (int slider, Real value) |
The user has moved one of the sliders you defined; here is the integer value you specified when you defined it, and the new value of the slider. More... | |
Static Public Attributes | |
static const unsigned | SpecialKeyOffset = 0x100 |
This abstract class defines methods to be called when the Visualizer reports user activity back to the simulation process. Derive a concrete event listener whose methods take appropriate actions when event of interest occur.
You only need to implement the methods you care about. The Visualizer provides an InputListener called InputSilo that is particularly useful for dealing with user input that is intended to affect the progress of a running simulation.
These represent modifications to the character that is passed into the keyPressed() method, including whether any of Shift/Control/Alt were down and whether a special non-ASCII code is being supplied, such as is required for an arrow key.
These values are or'ed together to form the second argument of the keyPressed() method.
Enumerator | |
---|---|
ShiftIsDown | Shift (left or right) |
ControlIsDown | Ctrl (left or right) |
AltIsDown | Alt (left or right) |
IsSpecialKey | Special non-ASCII keycode being used. |
These are the special keys that the Visualizer may report via the keyPressed() method.
All other keys are considered "ordinary".
|
inlinevirtual |
Destructor is virtual; be sure to override it if you need to clean up.
|
inlinevirtual |
This method is called when a user hits a keyboard key in the Visualizer window, unless that key is being intercepted by the Visualizer for its own purposes.
Ordinary ASCII characters 0-127 are represented by their own values; special keys like arrows and function keys are mapped to unique values > 255. You can check whether modifers & IsSpecialKey is true if you care; otherwise just mix the ordinary and special codes in a case statement. You can tell if any or all of Shift/Control/Alt were depressed when the key was hit by checking the modifiers. Note that for an ordinary capital letter you'll get the ASCII code for the capital as well as an indication that the Shift key was down. If caps lock was down you'll get the capital letter but no Shift modifier.
[in] | key | The ASCII character or special key code. |
[in] | modifiers | Whether Shift,Ctrl,Alt are down or key is special. |
true
if you have handled this key press and don't want any subsequent listeners called.
|
inlinevirtual |
The user has clicked one of the menu items you defined; here is the integer value you specified when you defined it.
[in] | menu | The id number of the menu in use. |
[in] | item | The menu item number that the user selected. |
true
if you have handled this menu click and don't want any subsequent listeners called.
|
inlinevirtual |
The user has moved one of the sliders you defined; here is the integer value you specified when you defined it, and the new value of the slider.
[in] | slider | The id number of the slider that moved. |
[in] | value | The new value represented by this slider position. |
true
if you have handled this move and don't want any subsequent listeners called.
|
static |