Commit 3dffbe16 authored by twanvl's avatar twanvl

More attempts to fix the DropDownList,

this design using wxPopupTransientWindow is probably not going to work, I should revert to the old version.
parent 54a60218
...@@ -386,8 +386,12 @@ void DropDownList::onScroll(wxScrollWinEvent& ev) { ...@@ -386,8 +386,12 @@ void DropDownList::onScroll(wxScrollWinEvent& ev) {
// ----------------------------------------------------------------------------- : DropDownList : Parent events // ----------------------------------------------------------------------------- : DropDownList : Parent events
bool DropDownList::onMouseInParent(wxMouseEvent& ev, bool open_in_place) { bool DropDownList::onMouseInParent(wxMouseEvent& ev, bool open_in_place) {
if (IsShown()) hide(false); if (IsShown()) {
else show(open_in_place, wxPoint(ev.GetX(), ev.GetY())); hide(false);
} else {
show(open_in_place, wxPoint(ev.GetX(), ev.GetY()));
ev.Skip(false); // Don't set the focus to the parent afterwards
}
return true; return true;
} }
...@@ -453,6 +457,12 @@ bool DropDownList::onCharInParent(wxKeyEvent& ev) { ...@@ -453,6 +457,12 @@ bool DropDownList::onCharInParent(wxKeyEvent& ev) {
return false; return false;
} }
void DropDownList::onKeyDown(wxKeyEvent& ev) {
// If we don't handle this event, then wxPopupTransientWindow desides to dismiss itself
// we can't wait for onChar
onCharInParent(ev);
}
// ----------------------------------------------------------------------------- : DropDownList : Event table // ----------------------------------------------------------------------------- : DropDownList : Event table
// Note: some DropDownList events get sent to the parent which in turn should send them to the DropDownList // Note: some DropDownList events get sent to the parent which in turn should send them to the DropDownList
...@@ -464,4 +474,5 @@ BEGIN_EVENT_TABLE(DropDownList,wxPopupWindow) ...@@ -464,4 +474,5 @@ BEGIN_EVENT_TABLE(DropDownList,wxPopupWindow)
EVT_LEAVE_WINDOW (DropDownList::onMouseLeave) EVT_LEAVE_WINDOW (DropDownList::onMouseLeave)
EVT_MOUSEWHEEL (DropDownList::onMouseWheel) EVT_MOUSEWHEEL (DropDownList::onMouseWheel)
EVT_SCROLLWIN (DropDownList::onScroll) EVT_SCROLLWIN (DropDownList::onScroll)
EVT_KEY_DOWN (DropDownList::onKeyDown)
END_EVENT_TABLE () END_EVENT_TABLE ()
...@@ -106,6 +106,7 @@ class DropDownList : public wxPopupTransientWindow { ...@@ -106,6 +106,7 @@ class DropDownList : public wxPopupTransientWindow {
void onMouseLeave(wxMouseEvent&); void onMouseLeave(wxMouseEvent&);
void onMouseWheel(wxMouseEvent& ev); void onMouseWheel(wxMouseEvent& ev);
void onScroll(wxScrollWinEvent&); void onScroll(wxScrollWinEvent&);
void onKeyDown(wxKeyEvent&);
// --------------------------------------------------- : Privates // --------------------------------------------------- : Privates
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment