From 854af01d1eb0219d05891d89b9904e8c50a78be7 Mon Sep 17 00:00:00 2001 From: bitcoin3us <115934595+bitcoin3us@users.noreply.github.com> Date: Tue, 15 Sep 2026 13:12:14 +0100 Subject: [PATCH] InputActivity/SettingActivity: document the optional selected_callback key Companion to MicroPythonOS/MicroPythonOS#298: `selected_callback(value)` fires on every radiobuttons/dropdown pick before Save (re-tapping the active radio fires again) so pickers can preview a choice live, e.g. play a sound. `changed_callback` semantics are unchanged. Co-Authored-By: Claude Fable 5.1 --- docs/frameworks/input-activity.md | 1 + docs/frameworks/setting-activity.md | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/frameworks/input-activity.md b/docs/frameworks/input-activity.md index 7005bea..b90073d 100644 --- a/docs/frameworks/input-activity.md +++ b/docs/frameworks/input-activity.md @@ -59,6 +59,7 @@ The `setting` dict has the same shape as the one used by `SettingActivity` and ` - **`min`** (int): Minimum value for `"slider"` (default: `0`) - **`max`** (int): Maximum value for `"slider"` (default: `100`) - **`allow_deselect`** (bool): For `radiobuttons`, allow the user to un-select the active option (default: `False`) +- **`selected_callback`** (callable): For `radiobuttons` and `dropdown`, called as `selected_callback(value)` every time the user picks an option (including re-tapping the already-selected radio), **before** Save. Use it to preview a choice live, e.g. play the sound the user just tapped. Independent of `changed_callback`, which still fires only after Save when the stored value changed. Exceptions inside it are logged and swallowed. (default: `None`) ## Result Contract diff --git a/docs/frameworks/setting-activity.md b/docs/frameworks/setting-activity.md index 97bb30a..f86a5d4 100644 --- a/docs/frameworks/setting-activity.md +++ b/docs/frameworks/setting-activity.md @@ -40,6 +40,7 @@ Each setting is defined as a dictionary with the following properties: ### Optional Properties - **`ui`** (string): UI type to use for editing. Options: `"textarea"` (default), `"radiobuttons"`, `"dropdown"`, `"slider"`, `"activity"` - **`ui_options`** (list): Options for `radiobuttons` and `dropdown` UI types. Each entry is a `(label, value)` tuple — the **label** appears on the radio button or dropdown row AND in the parent `SettingsActivity`'s value-label row beneath the title. The **value** is what gets stored in SharedPreferences. See [SettingsActivity → Display Labels for `ui_options`](settings-activity.md#display-labels-for-ui_options) for details. +- **`selected_callback`** (callable): Optional live-selection hook for `radiobuttons`/`dropdown`: `selected_callback(value)` fires on every pick before Save (so a picker can preview, e.g. play a sound), while `changed_callback` fires after Save. See [InputActivity](input-activity.md). - **`placeholder`** (string): Placeholder text for textarea input - **`default_value`** (string): Default value to select or fill in - **`changed_callback`** (function): Callback function called when the setting value changes