docs(custom_widget): make button sticky when clicking with mouse (#561)

This commit is contained in:
Dheepak Krishnamurthy 2023-10-06 05:17:14 -04:00 committed by GitHub
parent 089f8ba66a
commit e5caf170c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -252,8 +252,12 @@ fn handle_mouse_event(
_ => 2,
};
if old_selected_button != *selected_button {
button_states[old_selected_button] = State::Normal;
button_states[*selected_button] = State::Selected;
if button_states[old_selected_button] != State::Active {
button_states[old_selected_button] = State::Normal;
}
if button_states[*selected_button] != State::Active {
button_states[*selected_button] = State::Selected;
}
}
}
MouseEventKind::Down(MouseButton::Left) => {