From 8e18d21b3c41719ee6153e8f5e9ee62495dc4b15 Mon Sep 17 00:00:00 2001 From: twanvl Date: Fri, 31 Dec 2010 15:59:10 +0000 Subject: [PATCH] More attempts to fix the DropDownList, this design using wxPopupTransientWindow is probably not going to work, I should revert to the old version. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1573 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/gui/drop_down_list.cpp | 15 +++++++++++++-- src/gui/drop_down_list.hpp | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/gui/drop_down_list.cpp b/src/gui/drop_down_list.cpp index fd023f97..c994f50b 100644 --- a/src/gui/drop_down_list.cpp +++ b/src/gui/drop_down_list.cpp @@ -386,8 +386,12 @@ void DropDownList::onScroll(wxScrollWinEvent& ev) { // ----------------------------------------------------------------------------- : DropDownList : Parent events bool DropDownList::onMouseInParent(wxMouseEvent& ev, bool open_in_place) { - if (IsShown()) hide(false); - else show(open_in_place, wxPoint(ev.GetX(), ev.GetY())); + if (IsShown()) { + 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; } @@ -453,6 +457,12 @@ bool DropDownList::onCharInParent(wxKeyEvent& ev) { 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 // 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) EVT_LEAVE_WINDOW (DropDownList::onMouseLeave) EVT_MOUSEWHEEL (DropDownList::onMouseWheel) EVT_SCROLLWIN (DropDownList::onScroll) + EVT_KEY_DOWN (DropDownList::onKeyDown) END_EVENT_TABLE () diff --git a/src/gui/drop_down_list.hpp b/src/gui/drop_down_list.hpp index c359c8de..407ea960 100644 --- a/src/gui/drop_down_list.hpp +++ b/src/gui/drop_down_list.hpp @@ -106,6 +106,7 @@ class DropDownList : public wxPopupTransientWindow { void onMouseLeave(wxMouseEvent&); void onMouseWheel(wxMouseEvent& ev); void onScroll(wxScrollWinEvent&); + void onKeyDown(wxKeyEvent&); // --------------------------------------------------- : Privates