diff --git a/src/ui/combobox.cpp b/src/ui/combobox.cpp index 69135bd8d..f2160e9e2 100644 --- a/src/ui/combobox.cpp +++ b/src/ui/combobox.cpp @@ -411,8 +411,33 @@ bool ComboBoxEntry::onProcessMessage(Message* msg) if (m_comboBox->isEditable()) { getManager()->setFocus(this); } - else + else { + captureMouse(); return true; + } + break; + + case kMouseUpMessage: + if (hasCapture()) + releaseMouse(); + break; + + case kMouseMoveMessage: + if (hasCapture()) { + MouseMessage* mouseMsg = static_cast(msg); + Widget* pick = getManager()->pick(mouseMsg->position()); + Widget* listbox = m_comboBox->m_listbox; + + if (pick != NULL && (pick == listbox || pick->hasAncestor(listbox))) { + releaseMouse(); + + MouseMessage mouseMsg(kMouseDownMessage, + mouseMsg->buttons(), + mouseMsg->position()); + pick->sendMessage(&mouseMsg); + return true; + } + } break; } diff --git a/src/ui/combobox.h b/src/ui/combobox.h index 07736f51c..532b89d89 100644 --- a/src/ui/combobox.h +++ b/src/ui/combobox.h @@ -22,10 +22,12 @@ namespace ui { class ListItem; class Window; + class ComboBoxEntry; class ComboBoxListBox; class ComboBox : public Widget { + friend class ComboBoxEntry; friend class ComboBoxListBox; public: @@ -91,7 +93,7 @@ namespace ui { private: void onButtonClick(Event& ev); - Entry* m_entry; + ComboBoxEntry* m_entry; Button* m_button; Window* m_window; ComboBoxListBox* m_listbox; diff --git a/src/ui/widget.cpp b/src/ui/widget.cpp index a5a7e9312..2dc5a07d9 100644 --- a/src/ui/widget.cpp +++ b/src/ui/widget.cpp @@ -427,6 +427,15 @@ bool Widget::hasChild(Widget* child) return std::find(m_children.begin(), m_children.end(), child) != m_children.end(); } +bool Widget::hasAncestor(Widget* ancestor) +{ + for (Widget* widget=m_parent; widget; widget=widget->m_parent) { + if (widget == ancestor) + return true; + } + return false; +} + Widget* Widget::findChild(const char* id) { Widget* child; diff --git a/src/ui/widget.h b/src/ui/widget.h index f3dadd121..94ecfa06a 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h @@ -208,6 +208,7 @@ namespace ui { Widget* pick(const gfx::Point& pt); bool hasChild(Widget* child); + bool hasAncestor(Widget* ancestor); Widget* findChild(const char* id); // Returns a widget in the same window that is located "sibling".