mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-01 10:21:04 +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()) {
|
if (m_comboBox->isEditable()) {
|
||||||
getManager()->setFocus(this);
|
getManager()->setFocus(this);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
|
captureMouse();
|
||||||
return true;
|
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;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,12 @@ namespace ui {
|
|||||||
class ListItem;
|
class ListItem;
|
||||||
class Window;
|
class Window;
|
||||||
|
|
||||||
|
class ComboBoxEntry;
|
||||||
class ComboBoxListBox;
|
class ComboBoxListBox;
|
||||||
|
|
||||||
class ComboBox : public Widget
|
class ComboBox : public Widget
|
||||||
{
|
{
|
||||||
|
friend class ComboBoxEntry;
|
||||||
friend class ComboBoxListBox;
|
friend class ComboBoxListBox;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -91,7 +93,7 @@ namespace ui {
|
|||||||
private:
|
private:
|
||||||
void onButtonClick(Event& ev);
|
void onButtonClick(Event& ev);
|
||||||
|
|
||||||
Entry* m_entry;
|
ComboBoxEntry* m_entry;
|
||||||
Button* m_button;
|
Button* m_button;
|
||||||
Window* m_window;
|
Window* m_window;
|
||||||
ComboBoxListBox* m_listbox;
|
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();
|
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* Widget::findChild(const char* id)
|
||||||
{
|
{
|
||||||
Widget* child;
|
Widget* child;
|
||||||
|
@ -208,6 +208,7 @@ namespace ui {
|
|||||||
|
|
||||||
Widget* pick(const gfx::Point& pt);
|
Widget* pick(const gfx::Point& pt);
|
||||||
bool hasChild(Widget* child);
|
bool hasChild(Widget* child);
|
||||||
|
bool hasAncestor(Widget* ancestor);
|
||||||
Widget* findChild(const char* id);
|
Widget* findChild(const char* id);
|
||||||
|
|
||||||
// Returns a widget in the same window that is located "sibling".
|
// Returns a widget in the same window that is located "sibling".
|
||||||
|
Loading…
x
Reference in New Issue
Block a user