Simbody  3.7
SimTK::Visualizer::InputListener Class Reference

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...

+ Inheritance diagram for SimTK::Visualizer::InputListener:

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
 

Detailed Description

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.

See also
Visualizer::InputSilo

Member Enumeration Documentation

◆ Modifier

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.

◆ KeyCode

These are the special keys that the Visualizer may report via the keyPressed() method.

All other keys are considered "ordinary".

Enumerator
KeyControlC 
KeyBeep 
KeyBackspace 
KeyTab 
KeyLF 
KeyReturn 
KeyEnter 
KeyEsc 
KeyDelete 
KeyF1 
KeyF2 
KeyF3 
KeyF4 
KeyF5 
KeyF6 
KeyF7 
KeyF8 
KeyF9 
KeyF10 
KeyF11 
KeyF12 
KeyLeftArrow 
KeyUpArrow 
KeyRightArrow 
KeyDownArrow 
KeyPageUp 
KeyPageDown 
KeyHome 
KeyEnd 
KeyInsert 

Constructor & Destructor Documentation

◆ ~InputListener()

virtual SimTK::Visualizer::InputListener::~InputListener ( )
inlinevirtual

Destructor is virtual; be sure to override it if you need to clean up.

Member Function Documentation

◆ keyPressed()

virtual bool SimTK::Visualizer::InputListener::keyPressed ( unsigned  key,
unsigned  modifiers 
)
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.

Parameters
[in]keyThe ASCII character or special key code.
[in]modifiersWhether Shift,Ctrl,Alt are down or key is special.
Returns
Return true if you have handled this key press and don't want any subsequent listeners called.

◆ menuSelected()

virtual bool SimTK::Visualizer::InputListener::menuSelected ( int  menu,
int  item 
)
inlinevirtual

The user has clicked one of the menu items you defined; here is the integer value you specified when you defined it.

Parameters
[in]menuThe id number of the menu in use.
[in]itemThe menu item number that the user selected.
Returns
Return true if you have handled this menu click and don't want any subsequent listeners called.

◆ sliderMoved()

virtual bool SimTK::Visualizer::InputListener::sliderMoved ( int  slider,
Real  value 
)
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.

Parameters
[in]sliderThe id number of the slider that moved.
[in]valueThe new value represented by this slider position.
Returns
Return true if you have handled this move and don't want any subsequent listeners called.

Member Data Documentation

◆ SpecialKeyOffset

const unsigned SimTK::Visualizer::InputListener::SpecialKeyOffset = 0x100
static

The documentation for this class was generated from the following file: