fix(segmented-button): crash when context menu is unassigned
This commit is contained in:
parent
537486a4ab
commit
c0b653f506
1 changed files with 17 additions and 15 deletions
|
|
@ -883,23 +883,25 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present a context menu on a right click event.
|
// Present a context menu on a right click event.
|
||||||
if let Some(on_context) = self.on_context.as_ref() {
|
if self.context_menu.is_some() {
|
||||||
if right_button_released(&event)
|
if let Some(on_context) = self.on_context.as_ref() {
|
||||||
|| (touch_lifted(&event) && fingers_pressed == 2)
|
if right_button_released(&event)
|
||||||
{
|
|| (touch_lifted(&event) && fingers_pressed == 2)
|
||||||
state.show_context = Some(key);
|
{
|
||||||
state.context_cursor =
|
state.show_context = Some(key);
|
||||||
cursor_position.position().unwrap_or_default();
|
state.context_cursor =
|
||||||
state.focused = true;
|
cursor_position.position().unwrap_or_default();
|
||||||
state.focused_item = Item::Tab(key);
|
state.focused = true;
|
||||||
|
state.focused_item = Item::Tab(key);
|
||||||
|
|
||||||
let menu_state =
|
let menu_state =
|
||||||
tree.children[0].state.downcast_mut::<MenuBarState>();
|
tree.children[0].state.downcast_mut::<MenuBarState>();
|
||||||
menu_state.open = true;
|
menu_state.open = true;
|
||||||
menu_state.view_cursor = cursor_position;
|
menu_state.view_cursor = cursor_position;
|
||||||
|
|
||||||
shell.publish(on_context(key));
|
shell.publish(on_context(key));
|
||||||
return event::Status::Captured;
|
return event::Status::Captured;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue