`msg_ok()` creates an OK message dialog object.
Use it for information messages where the user only acknowledges the message.
`msg_ok` is not cloneable because it represents dialog configuration, result state, and optional asynchronous callback state.
Creates an OK message dialog.
| Item | Description |
|---|---|
| Syntax | `msg_ok()` |
| Arguments | none |
| Returns | msg_ok object |
Example:
dlg = msg_ok();
| 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 the result action is OK. |
| `cancel` | boolean | `true` when the result action is Cancel. |
| `save` | boolean | Save flag in the result map. Usually `false` for `msg_ok`. |
Properties are read-only. Use methods such as `title(text)` and `message(text)` to change dialog configuration.
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`.
Sets the dialog title.
| Argument | Type | Description |
|---|---|---|
| `text` | string | Title text. |
Returns: msg_ok object.
Example:
dlg = msg_ok().title('Information');
Sets the message text.
| Argument | Type | Description |
|---|---|---|
| `text` | string | Message text. |
Returns: msg_ok object.
Example:
dlg = msg_ok().message('Operation finished.');
Shows or hides dialog buttons.
| Argument | Type | Description |
|---|---|---|
| `enabled` | boolean | Button visibility state. |
Returns: msg_ok object.
Example:
dlg = msg_ok().buttons(true);
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 object.
When `on_result()` is used, `show()` displays the dialog and returns the dialog object immediately. The callback receives one argument: a result `map`.
Example:
function done(result) { if (result.ok) { print('confirmed'); } } msg_ok() .title('Information') .message('Done') .on_result(done) .show();
Shows the dialog.
| Item | Description |
|---|---|
| Syntax | `msg_ok.show()` |
| Arguments | none |
| Returns | map or msg_ok 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() .title('Information') .message('Program complete') .show(); if (result.ok) { print('OK pressed'); }
Clicks OK on an active asynchronous dialog.
| Item | Description |
|---|---|
| Syntax | `msg_ok.click_ok()` |
| Arguments | none |
| Returns | boolean-style number |
Returns `true` when the click was accepted.
Clicks Close on an active asynchronous dialog.
| Item | Description |
|---|---|
| Syntax | `msg_ok.click_close()` |
| Arguments | none |
| Returns | boolean-style number |
Returns `true` when the click was accepted.
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: file_save
Next: msg_ok_cancel