UI Types for Applets

UI Types for Applets

Top  Previous  Next

JavaScript, Lua Apps and Widgets use identical Input and Output types.  Here are the selections.

Inputs

App UItype1 

Draggable - any points in the Mechanical Expressions model constrained by variable Coordinates or a variable parameter for the Point Proportional constraint can be set as Draggable points in the JavaScript, Lua app or Widget.  The point's constraint variables, however, cannot be functions or negative; only positive variables are allowed for defining draggable points. I.e., the value of the variable may very well be negative, but using -t as the point proportional parameter or (x, 3*x) as a point's  coordinates prevents the point from being draggable.

Slider - takes it's range from the values specified in the MX Animation in the Variables panel. warning  Please note - not all browsers support sliders.

Text Box - lets you enter any numeric value for the variable.

For a function, you have the choice of a single line Text Box or a Multiline Text Box. Remember to use the JavaScript return statement in multi-line statements in JavaScript Apps or Widgets.

js input multilint 

warning  Note:  when defining variables or functions in the edit field of JavaScript Apps or Widgets, remember that JavaScript does not use "^" to denote a power. xsq  must be written: pow(X,2).

Advance Button - displays the variable Label on a button and increments the variable when clicked.  Uses the range and direction from the MX animation settings.  If you used decimal values in MX, the values a reduced to integers.

Media Controls - works like the Advance Button but gives you  some additional options.  For values within the specified range, you can:

  • increment or decrement regardless of the mode setting
  • jump to a specific integer value by typing (as in the Text Box mode)
  • jump to the beginning or end of the range

Timer - this is great for making Clock Applets and smooth animations.  Here are the Timer Styles:

timer style 

The hour, minutes and seconds are taken from your computer's clock.

Random - gives the specified variable a single random value within the range set in the MX Variables tool panel.  To  change the variable's value to another  random number click the Reload button reload .

Outputs

Any measurements which are present in the Mechanical Expressions model may be chosen as outputs for the JavaScript, Lua Apps or Widgets.  Check the Show in Export checkbox and modify the Label if needed.

App Outputs 

UI Type - Plain Text or Show / Hide Button which is a toggle.