mirror of
https://github.com/clangen/musikcube.git
synced 2025-02-06 03:39:50 +00:00
Fix key press event bubbling for nested layouts.
This commit is contained in:
parent
9a0b828c51
commit
5490030447
@ -493,6 +493,19 @@ bool LayoutBase::KeyPress(const std::string& key) {
|
||||
this->FocusNext();
|
||||
return true;
|
||||
}
|
||||
/* we find the focus recursively, then let the child deepest in the
|
||||
hierarchy process the key event. if that fails we move up to its parent,
|
||||
and so on until we reach ourself. */
|
||||
auto focus = this->GetFocus().get();
|
||||
while (focus != this) {
|
||||
auto asKeyHandler = dynamic_cast<IKeyHandler*>(focus);
|
||||
if (asKeyHandler) {
|
||||
if (asKeyHandler->KeyPress(key)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
focus = focus->GetParent();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user