mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-28 13:48:13 +08:00
Make RadioInput accept optional selected_index
This commit is contained in:
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user