mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-27 20:37:11 +00:00
Now you can press a mouse button in a ComboBoxEntry and drag the mouse to the ComboBoxListBox (issue 339)
This commit is contained in:
parent
7251f4b70a
commit
3cbf3e122f
@ -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<MouseMessage*>(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;
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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".
|
||||
|
Loading…
x
Reference in New Issue
Block a user