mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-08 12:16:17 -04:00
Deselect Sub-Menu On Focus Change (#710)
- Unselect any previous items when focusing a new one This might be way over-inclusive so it should be scrutinized harshly (but fixes #672)
This commit is contained in:
+10
-1
@@ -126,11 +126,20 @@ Component& Pane::register_control(
|
||||
}
|
||||
});
|
||||
component.listen(component.root(), Rml::EventId::Focus,
|
||||
[&component, &nextPane, callback = std::move(callback)](Rml::Event&) {
|
||||
[this, &component, &nextPane, callback = std::move(callback)](Rml::Event&) {
|
||||
if (component.disabled()) {
|
||||
return;
|
||||
}
|
||||
nextPane.clear();
|
||||
|
||||
// If an item is already selected, deselect
|
||||
for (const auto& child : mChildren) {
|
||||
if (child->selected()) {
|
||||
set_selected_item(-1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
callback(nextPane);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user