Creating OS X Dashboard Widgets

Creating OS X Dashboard Widgets

Top  Previous  Next

Dashboard Widgets are very similar to JavaScript Applets, but they sit on The Mac Dashboard. Select File / Export /OS X Dashboard Widgets.

Fill out the details in the OS X Dashboard Widget Generator dialog.

widget dialog 

Output directory - tells Gx where to put the files.  It will create a folder: name.wdgt containing all the components of the widget.

Widget Name - is the name of the folder and the main .html file.

Auto-scale - when set to True, the Widget automatically rescales the  drawing when the user changes the value of one of the inputs; when set to False, you click-and-drag a rectangle around the drawing after you click Ok.

Width and Height specify the size of the drawing in the Widget box.

Widget Title, Widget Header Text, and Widget Footer Text - enter your text for these sections.

Since header and footer text may be several lines long, You can go back and change these text boxes before you close  the dialog:

  • select the text entry box
  • click the dots  to display the dialog
  • enter or edit  text, then click Ok.

Note:  you can insert html code into the header and footer text, e.g. to make a word in the footer text bold:

widget text 

CSS file (optional) - you can attach your favorite Cascading Style Sheet, without having to reproduce it every time.

Inputs - lets you choose which variables the user will be able to change, what text Label identifies the variable and what type of control to use.

Any variables in your Gx model may be selected as input variables in the Widget.  You can choose whether to use an edit field or a slider to control the variable.

Any points in the Geometry Expressions model constrained by variable Coordinates or a variable parameter for the Point Proportional constraint can be set as Draggable in the widget.  These variables, however, cannot be expressions 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 will not work.

Input functions can be modified in the Text Box field with single or multi-line JavaScript notation. Remember to use return in multi-line JavaScript statements.

js input multilint 

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

Outputs - lets you choose which outputs will appear in the applet, and their text Label.

Any measurements which are present in the Geometry Expressions model may be chosen as outputs for the widget.  Select True from the Show in Export line.