Make RadioInput accept optional selected_index

This commit is contained in:
Keavon Chambers
2023-09-11 15:40:05 -07:00
parent b29acbd784
commit 88bdf9580f
12 changed files with 23 additions and 23 deletions
@@ -211,7 +211,7 @@ impl<F: Fn(&MessageDiscriminant) -> Vec<KeysGroup>> MessageHandler<LayoutMessage
Widget::PopoverButton(_) => {}
Widget::RadioInput(radio_input) => {
let update_value = value.as_u64().expect("RadioInput update was not of type: u64");
radio_input.selected_index = update_value as u32;
radio_input.selected_index = Some(update_value as u32);
let callback_message = (radio_input.entries[update_value as usize].on_update.callback)(&());
responses.add(callback_message);
}
@@ -340,7 +340,7 @@ pub struct RadioInput {
// This uses `u32` instead of `usize` since it will be serialized as a normal JS number (replace this with `usize` after switching to a Rust-based GUI)
#[serde(rename = "selectedIndex")]
pub selected_index: u32,
pub selected_index: Option<u32>,
}
#[derive(Clone, Default, Derivative, Serialize, Deserialize, WidgetBuilder, specta::Type)]