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:dialog_msg_ok_cancel

msg_ok_cancel

`msg_ok_cancel()` creates an OK/Cancel message dialog object.

Use it when the user must confirm or cancel an action.

`msg_ok_cancel` is not cloneable because it represents dialog configuration, result state, and optional asynchronous callback state.

Constructor

msg_ok_cancel()

Creates an OK/Cancel message dialog.

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

Example:

dlg = msg_ok_cancel();

Properties

Property Type Description
`title` string Dialog title.
`message` string Dialog message text.
`buttons` boolean Whether dialog buttons are shown.
`has_result` boolean `true` after the dialog has produced a result.
`action` string Result action: `ok`, `cancel`, or `none`.
`ok` boolean `true` when OK was selected.
`cancel` boolean `true` when Cancel was selected.
`save` boolean Save flag in the result map. Usually `false` for `msg_ok_cancel`.

Properties are read-only. Use methods such as `title(text)` and `message(text)` to change dialog configuration.


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 `msg_ok_cancel`.


Methods

title(text)

Sets the dialog title.

Argument Type Description
`text` string Title text.

Returns: msg_ok_cancel object.


message(text)

Sets the message text.

Argument Type Description
`text` string Message text.

Returns: msg_ok_cancel object.


buttons(enabled)

Shows or hides dialog buttons.

Argument Type Description
`enabled` boolean Button visibility state.

Returns: msg_ok_cancel object.


on_result(callback)

Sets a callback for asynchronous result handling.

Argument Type Description
`callback` callable object Function reference, method reference, or other object that implements `call(result)`.

Returns: msg_ok_cancel object.

When `on_result()` is used, `show()` displays the dialog and returns the dialog object immediately. The callback receives one argument: a result `map`.


show()

Shows the dialog.

Item Description
Syntax `msg_ok_cancel.show()`
Arguments none
Returns map or msg_ok_cancel object

Without `on_result()`, `show()` blocks until the dialog is closed and returns a result `map`.

With `on_result(callback)`, `show()` returns the dialog object immediately.

Example:

result = msg_ok_cancel()
    .title('Confirm')
    .message('Start probing?')
    .show();
 
if (result.ok)
{
    print('start');
}
else
{
    print('cancelled');
}

click_ok()

Clicks OK on an active asynchronous dialog.

Item Description
Syntax `msg_ok_cancel.click_ok()`
Arguments none
Returns boolean-style number

Returns `true` when the click was accepted.


click_close()

Clicks Close on an active asynchronous dialog.

Item Description
Syntax `msg_ok_cancel.click_close()`
Arguments none
Returns boolean-style number

Returns `true` when the click was accepted.


Result Map

Synchronous `show()` returns a result `map`. Asynchronous `on_result(callback)` callbacks receive the same kind of result map.

Key Type Description
`action` string `ok`, `cancel`, or `none`. For Yes/No dialogs, Yes is reported as `ok` and No/Close as `cancel`.
`action_code` number Numeric host action code.
`ok` boolean `true` when the result action is OK/Yes.
`cancel` boolean `true` when the result action is Cancel/No/Close.
`affirmative` boolean `true` for affirmative choices such as OK or Yes.
`save` boolean Save flag from the host dialog result.
`password` string Password text. Empty for non-password dialogs.

Previous: msg_ok

Next: msg_yes_no

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

Page Tools