Programming Inteface Controls in ZDoc

From ZCubes Wiki
Jump to navigation Jump to search

Picking and Placing Controls in ZSpace

Selecting Left Main Z Icon/Advanced/Controls launches the Controls panel. The controls panel has lots of choices, and these controls can be inserted into ZCubes by simply clicking (to insert at selection) or simply dragged and dropped into an appropriate part of ZSpace.

Z Control List

Controls include Numeric Range, Textbox, Button, Textarea, Checkbox, Checkbox Group, Radiobutton, Radiobutton Group, Image, ImgButton, Label, Single and Multiple Dropdown, Form, Spinner Control, etc. Also included are convenient small Calci compontents, that has descriptions on the left, top, bottom and right of a single cell, and these are really useful to get calci components with labels in different parts of the document.

Please drag or click for controls with Shift or Ctrl pressed to automatically trigger RECALC() on spreadsheets every time this controls raises an oninput or onchange event. Note that oninput will trigger for each character typed into the control.

Attaching Events to Controls

Right clicking on a control will launch the Properties Editor for the Control.

Attaching Events to Controls

Events can show a set of events that can be Attached to. For example, None, OnClick, OnBlur, OnChange, OnInput, etc.

Events can be associated to an Action, including None, Opening a Link, Showing a Message, Running a ZCommand, Run Scripts, etc. Run Scripts are the most interesting, because any z^3 code can be given here, including RECALC() or a code trigger (such as EVALCODEX("codesegment1") below). The script can be complex code, if need be.

The value in the controls can be numbers, text, names of variables, and any arbitrary code that can represent the value of the control. This control value can be referred to from a spreadsheet by pressing = in a cell, followed by clicking on a control. A formula could look like ==1Space!zcontrol1

Connecting Spreadsheet to ZControls

If a control value is changed, any references from Calci automatically will pull in the new value of the control, and trigger a spreadsheet recalc.  

Triggering Code in Code Editor

Manually clicking the Run Button on a command window can trigger calculations in that code segment. Please note that each code segment has an id, which can be seen in the status if the mouse is hovered over the code segment.

The function EVALCODEX(codesegmentid) will trigger evaluation of the named code segment.

Server Based Languages

If code segment contains a server-based language such as Python or APL, EVALCODEX(codesegmentid) will trigger the calculation, such as if triggered from a ZControl button. Please not that if a Jupyter Kernal is present, please provide the token and port to Jupyter, so that Z can connect to the backend (if security is present). More information is available on [1].

Z to Server Kernal

Once connected, the interaction between client and server can continue continuously for any language supported on the serverside, allowing Z to interactively connect and process Python, APL, Java, C++, Typescript, FORTRAN, LISP, etc. This feature is explained in more detail in OmniGlot