`msg_password()` creates a password OK/Cancel dialog object.
Use it when the user must enter a password or other hidden text.
`msg_password` is not cloneable because it represents dialog configuration, result state, and optional asynchronous callback state.
Creates a password dialog.
| Item | Description |
|---|---|
| Syntax | `msg_password()` |
| Arguments | none |
| Returns | msg_password object |
Example:
dlg = msg_password();
| Property | Type | Description |
|---|---|---|
| `title` | string | Dialog title. |
| `message` | string | Dialog message text. |
| `buttons` | boolean | Whether dialog buttons are shown. |
| `password_label` | string | Label shown next to the password field. |
| `password` | string | Initial password before showing; result password after the dialog returns. |
| `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_password`. |
Properties are read-only. Use methods such as `password_label(text)` and `password(text)` to change password 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_password`.
Sets the dialog title.
| Argument | Type | Description |
|---|---|---|
| `text` | string | Title text. |
Returns: msg_password object.
Sets the message text.
| Argument | Type | Description |
|---|---|---|
| `text` | string | Message text. |
Returns: msg_password object.
Shows or hides dialog buttons.
| Argument | Type | Description |
|---|---|---|
| `enabled` | boolean | Button visibility state. |
Returns: msg_password object.
Sets the label shown next to the password field.
| Argument | Type | Description |
|---|---|---|
| `text` | string | Password field label. |
Returns: msg_password object.
Example:
dlg = msg_password().password_label('Code:');
Sets the initial password text.
| Argument | Type | Description |
|---|---|---|
| `text` | string | Initial password text. |
Returns: msg_password object.
Example:
dlg = msg_password().password('abc');
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_password object.
When `on_result()` is used, `show()` displays the dialog and returns the dialog object immediately. The callback receives one argument: a result `map`.
Shows the dialog.
| Item | Description |
|---|---|
| Syntax | `msg_password.show()` |
| Arguments | none |
| Returns | map or msg_password 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_password() .title('Password') .message('Enter password') .password_label('Password:') .show(); if (result.ok) { print(result.password); }
Clicks OK on an active asynchronous dialog.
| Item | Description |
|---|---|
| Syntax | `msg_password.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_password.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: msg_yes_no
Next: GUI objects