GUI Application

The GUI Framework makes a desktop window from one Events graph. You choose GUIApplication as the graph's base type, describe the screen in a callback, and answer what the person presses in another. It is how the GUI › Calculator and GUI › Pronounce examples in Divooka Explore are made. For the other ways to build an interface and how to choose, see Desktop GUI Applications.

The callbacks

Callback When it runs What a graph does there
Start Before the window exists Set the window's title and size (Set Window Title, Set Window Size)
Build When the window is ready, and again after Rebuild Describe the screen
Clicked A button was pressed, or Enter in a text box that has an intent Act on what it meant
Key Pressed A key was pressed Work out which of the screen's own buttons it means, and Press it
Update Once every frame Animate, or ask Was Clicked and Was Key Pressed

Describing the screen

A screen is a list of statements in Build, run in order. A container is opened, everything added goes into the innermost open one, and End closes it:

Begin Card
  Add Label "0"   name: display   role: Display   alignment: Right
End
Begin Grid   columns: 4   rows: 5
  Add Button "7"
  Add Button "8"
  ...
End
Statements What they add
Begin Column, Begin Row, Begin Grid, Begin Card … End Containers. A grid's cells are equal and fill in reading order unless Place In Grid says otherwise
Add Label Text, with a role (Body, Caption, Subtitle, Title, Display) and an alignment
Add Button Something to press. What it means - its intent - is its caption unless you give it another, so a keypad's 7 means 7
Add Text Box A line the person can edit, read with Get Text. Give it an intent and Enter in the box is a press of that intent, as a button's is
Add Spacer, Add Divider Room, or a rule
Set Stretch, Set Size, Place In Grid, Set Padding, Set Text Fit Adjust the element added last. Set Text Fit draws text as large as fits its box, so it grows with the window; set on a container, it holds for everything inside

A Build that leaves a container open, a name used twice, or Set Text on a name that does not exist is refused with a message naming the problem, rather than failing quietly.

Changing it afterwards

Elements added with a name are reached by that name: Set Text, Get Text, Set Enabled, Set Visible, Has Element. Text that changes needs nothing more - it is on screen the same frame. Rebuild runs Build again, for a screen whose shape changes. Close ends the application, and Show Notice shows a short notice in a corner.

Presses and keys

Every press arrives at Clicked with its intent, which is text, so the graph compares it with Equals and branches - or, for a keypad, checks it with one Contains. A text box and the button beside it can share one intent, so pressing the button and pressing Enter in the box run the same arm.

A key arrives at Key Pressed as what it typed - 7, +, A - or by name when it types nothing: Enter, Escape, Backspace, the arrows, F1 to F12 and the rest. Press turns a key into a press of the screen's own button, so the rule for what a key does is written once, in Clicked. That is the whole of the Calculator's keyboard. While a text box has the keyboard it keeps the keys typed into it; only Enter reaches the screen, as its intent.

Running it

The application opens a window of its own, in the editor as well as in Divooka Player and in a program published from Divooka Compute.

See also