Widgets

From SimPhy 3.0 onwards there is support of widgets that can be added to simulations. few of widgets are just for information purpose (like label and text widget), while other widgets respond to event by associating scripts with them(like button, slider etc).

The common widgets used are:

  • Non Scriptable Widgets (label and Text)
  • Button
  • Slider
  • List and Combo
  • Timer

Scripting on Widget Events

Below are examples for Few of most common widgets can have script
Button: allows user to write script on its onClick() event. for example

function button_onclick(){
    var disc = world.addDisc(0.3)
}

adds disc of radius 0.3 at origin whenever button is pressed.

Slider: allows user to write script on its onChange() event. for example

function slider_onchange(){
    disc.setFriction(value)
}

changes friction on disc equal to value of slider

CheckBox: allows user to write script on its onChange() event. for example

function checkbox_onclick(){
   disc.setVisible(value)
}

toggles visibility of disc when check box is checked/unchecked

TextBox: allows to display text with minimal html support

Panel: acts as container of widget, when a widget is placed over it, the widget sticks to the panel and moves whenever panel is moved

Overall the latest features of simPHY makes is more flexible to create simulations and make few boring games.