Sidebar

Home



Expressions V4


Tutorials

How-To

Reference

  Lexical basics
  Type system
  Variables and assignment
  Operators
  Expression rules
  Control flow
  Functions
  Built-in functions
   None and NaN
   Arithmetic
   Algebra
   Logarithmic and Exponential
   Trigonometric
   Rounding and Centering
   Strings
   Output, Formatting, Clipboard, and Errors
   Dialog Functions
   Platform and Paths
  Methods and properties
  Built-in methods
   Common Value Methods
   Number Methods
   String Basic Methods
   String Slice Methods
   String Parsing Methods
   String Formatting Methods
   String Regex Methods
   String Trim and Case Methods
  Objects
  Built-in objects
   Global objects
    settings
    controller
    session
    python
   Collections
    array
    map
    bytes
   File Format I/O
    image_data
    image_stream
   Utils
    crypto
    timer
   Comm
    serial
   Dialogs
    file_open
    file_save
    msg_ok
    msg_ok_cancel
    msg_yes_no
    msg_password
   GUI objects
    window
    panel
    group
    splitpanel
    label
    textbutton
    drawablebutton
    togglebutton
    togglegroup
    textinput
    textedit
    numinput
    slider
    combobox
    listbox
    progressbar
    led
    separator
    menu
    image
    snake
  Classes and user-defined objects
  Include system
  Error model
  Execution model and sessions
  Host integration
  Limits and performance
  Formal reference
  Glossary

Cookbook

exprv4:reference:objects:gui_group

group

`group()` creates a titled container for related controls.

Constructor

group()

Creates a group object.

Item Description
Syntax `group()`
Arguments none
Returns group object

Example:

g = group().text('Settings').position(10, 10).size(300, 140);

Properties

Properties are read-only. Use methods to change GUI object state.

Property Type Description
`position_x` number Current x position.
`position_y` number Current y position.
`size_width` number Current width.
`size_height` number Current height.
`visible` boolean Current visible state.
`enabled` boolean Current enabled state.
`text` string Current group title text.
`border` number Current border size. `0` means no border.
`fit_parent` boolean `true` when `size(-1, -1)` was used to fit the parent area.

Common Object Methods

to_string()

Returns a display string for the object.

Item Description
Syntax `value.to_string()`
Arguments none
Returns string

Example:

text = value.to_string();

`clone()` is not supported for `group`.


Most visible GUI controls support these methods.

position(x, y)

Sets the component position in pixels.

Item Description
Syntax `component.position(x, y)`
Arguments `x`: x position; `y`: y position
Returns component object

Example:

label().position(20, 10);

size(width, height)

Sets the component size in pixels. Width and height are clamped to at least `1`.

Some container objects, such as `panel()` and `group()`, use `size(-1, -1)` as a special fit-parent mode.

Item Description
Syntax `component.size(width, height)`
Arguments `width`: width in pixels; `height`: height in pixels
Returns component object

Example:

textinput().size(220, 26);

visible(enabled)

Shows or hides the component.

Item Description
Syntax `component.visible(enabled)`
Arguments `enabled`: boolean
Returns component object

Example:

status.visible(false);

enabled(enabled)

Enables or disables user interaction with the component.

Item Description
Syntax `component.enabled(enabled)`
Arguments `enabled`: boolean
Returns component object

Example:

run_button.enabled(false);

Methods

text(label)

Sets the group title text.

Item Description
Syntax `group.text(label)`
Arguments `label`: title text shown by the group
Returns group object

Example:

g = group().text('Settings');

border(size)

Sets group border size. Values below `0` are clamped to `0`.

Item Description
Syntax `group.border(size)`
Arguments `size`: border size in pixels
Returns group object

Example:

g = group().border(1);

on_resize(callback)

Sets a callback called after the group content area is resized.

Item Description
Syntax `group.on_resize(callback)`
Arguments `callback`: callable with four arguments: `x`, `y`, `width`, `height`
Returns group object

The callback receives the usable content area after group border/title spacing is subtracted.

Example:

function group_resized(x, y, width, height)
{
    print('group size: ', width, ' x ', height);
}
 
g = group().on_resize(group_resized);

add(component)

Adds a child GUI component to the group.

A component can belong to only one container. Adding the same component again to the same group is ignored; adding a component that already belongs to another container raises an error.

Item Description
Syntax `group.add(component)`
Arguments `component`: GUI component object
Returns group object

Example:

g = group().text('Settings').position(10, 10).size(300, 140);
g.add(togglebutton().position(12, 30).size(180, 24).text('Enabled'));

Example

g = group().text('Settings').position(10, 10).size(300, 140);
g.add(togglebutton().position(12, 30).size(180, 24).text('Enabled'));
window().title('Group').size(340, 210).add(g).show();

Previous: panel

Next: splitpanel

exprv4/reference/objects/gui_group.txt · Last modified: by andrej

Page Tools