prevent dropdown from closing when moving to parent or child

This commit is contained in:
GenevensiS
2026-04-09 19:30:17 +02:00
parent a99c603ffb
commit 4d1c7aae96
20 changed files with 65 additions and 38 deletions
+15 -3
View File
@@ -471,9 +471,13 @@ void DropDownList::onMotion(wxMouseEvent& ev) {
}
void DropDownList::onMouseLeave(wxMouseEvent& ev) {
if (close_on_mouse_out) {
wxSize cs = GetClientSize();
if (ev.GetX() < 0 || ev.GetY() < 0 || ev.GetX() >= cs.x || ev.GetY() >= cs.y) {
if (close_on_mouse_out) {
wxPoint screen_pos = ClientToScreen(ev.GetPosition());
bool in_parent = parent_menu ? parent_menu->isInRect(screen_pos) : false;
bool in_child = open_sub_menu ? open_sub_menu->isInRect(screen_pos) : false;
wxSize cs = GetClientSize();
bool in_self = !(ev.GetX() < 0 || ev.GetY() < 0 || ev.GetX() >= cs.x || ev.GetY() >= cs.y);
if (!(in_parent || in_child || in_self)) {
hide(false); // outside box; hide it
ev.Skip();
return;
@@ -481,6 +485,14 @@ void DropDownList::onMouseLeave(wxMouseEvent& ev) {
}
}
bool DropDownList::isInRect(wxPoint screen_pos) {
wxRect rect = GetRect();
if (screen_pos.x < rect.x || screen_pos.y < rect.y || screen_pos.x > rect.x+rect.width || screen_pos.y > rect.y+rect.height) {
return false;
}
return true;
}
void DropDownList::onMouseWheel(wxMouseEvent& ev) {
scrollTo(visible_start - item_size.height * ev.GetWheelRotation() / ev.GetWheelDelta());
}