ui.eh
Screen based user interface. More...
Constants
Types
Functions
Description
Graphical application defines one or more full screen windows,
in terminology of Alchemy OS called
Screens. You may choose
from different types of screens:
-
the set of predefined screens in stdscreens.eh;
-
canvas from canvas.eh on which you can draw freely;
-
form from form.eh to build high level dialogs.
Initially application has no active screen (is in console mode). Switching
to graphical mode is done by calling
ui_set_screen(screen).
If argument is
null
then screen is removed from the display and
application switches back to the console mode.
Screen menus
Every screen has a menu. This menu always contains item "Switch to..." which
is used to switch between graphical applications. Custom menu items may be
attached to a screen or detached from it anytime. Menu items are values of
type
Menu.
New menu is created with constructor new_menu(label, priority).
Priority determines how menus are organized. The less priority number the
higher menu item will be in the menu.
Event handling
When user interacts with the screen, application generates an
UIEvent
value that contains information about what happened and on which screen.
These events are then read by functions
ui_read_event and
ui_wait_event.
ui_wait_event()
will wait until something happens on the screen, and then return
that event. This function is appropriate when you just passively waiting for the event.
ui_read_event()
returns immediately. If there are no events, it returns null
.
It is appropriate for cases when you constantly need to do something (redraw screen for example).
Simple example
Constant details
Event of this kind is generated when screen gains focus.
The field
UIEvent.value
is
null
for this kind of event.
Event of this kind is generated when screen losts focus.
The field
UIEvent.value
is
null
for this kind of event.
Event of this kind is generated when user chooses screen menu item.
In this case the field
UIEvent.value
will contain chosen
Menu item.
Event of this kind is generated when user activates interactive item.
In this case the field
UIEvent.value
will contain activated
Item.
Event of this kind is generated by canvas on key press.
The field
UIEvent.value
will contain
Int code of pressed key.
Event of this kind is generated by canvas repeatedly if key is held down.
The field
UIEvent.value
will contain
Int code of pressed key.
Event of this kind is generated by canvas on key release.
The field
UIEvent.value
will contain
Int code of pressed key.
Event of this kind is generated by canvas when the pointer is pressed (screen touched).
In this case
UIEvent.value
will contain
Point value with coordinates of pointer position.
Event of this kind is generated by canvas when the pointer is released.
In this case
UIEvent.value
will contain
Point value with coordinates of pointer position.
Event of this kind is generated by canvas when the pointer is dragged.
In this case
UIEvent.value
will contain
Point value with coordinates of pointer position.
Type details
An application window which can be shown on the device display.
Menu item that can be attached to a screen.
An event from the graphical user interface.
Fields:
-
kind - kind of event, one of predefined
EV_*
constants;
-
source - screen that generated this event;
-
value - depends on the event kind. See description of each
EV_*
constant to find out particular value.
2-dimensional point on the canvas.
Used as return value in pointer events.
Function details
def ui_set_app_title(title: String);
|
Sets default title for all screens of application.
def ui_set_app_icon(icon: Image);
|
Sets application icon, which will appear in "Switch to..." dialog.
Requests device to vibrate for specified number of milliseconds.
This function returns immediately, vibration happens in background. To stop
vibrator, call this function with
0
. Note, that device may limit or
override duration of vibration.
Returns true
if vibration is supported, false
otherwise.
Requests device to flash backlight for specified number of milliseconds.
The exact effect is device dependent, examples are are cycling the backlight on and off
or from dim to bright repeatedly.
This function returns immediately, flashing happens in background. To stop
flashing effect, call this function with
0
. Note, that device may limit or
override duration of flashing.
Returns true
if flashing is supported, false
otherwise.
def Screen.get_height(): Int;
|
Returns height of the screen available to application.
def Screen.get_width(): Int;
|
Returns width of the screen available to application.
def Screen.get_title(): String;
|
Returns title of the screen.
def Screen.set_title(title: String);
|
Sets new title to the screen.
def Screen.is_shown(): Bool;
|
Returns
true
if this screen is shown on the phone display.
Returns current screen associated with the application.
If application is in console mode, this method returns
null
.
def ui_set_screen(scr: Screen);
|
Shows given screen on the display.
Creates new menu item that can be attached to a screen.
Menu label is defined by
text argument. Priority determines
how menus are arranged in a list - lower number means higher priority.
Returns text label of this menu item.
def Menu.get_priority(): Int;
|
Returns priority of given menu item.
def Screen.add_menu(menu: Menu);
|
Attaches given menu item to the screen.
def Screen.remove_menu(menu: Menu);
|
Detaches given menu item from the screen.
Reads next event from the event queue of the application.
If there are no pending events this function returns
null
.
Reads next event from the event queue of the application.
If there are no pending events this function waits until an event is available.