]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/combocmn.cpp
Fix numpad Del not working in wxRTC
[wxWidgets.git] / src / common / combocmn.cpp
index 50449b2344ca0e4a1d1fe3642ac1e60d99b770f8..17b6a376639c6a4a1c0dff1728523b20f9aa3180 100644 (file)
 //     reflected (or something like that - atleast commenting out ->Hide()
 //     seemed to eliminate the position change).
 
+// NB: Let's not be afraid to use wxGTK's wxPopupTransientWindow as a
+//     'perfect' popup, as it can succesfully host child controls even in
+//     popups that are shown in modal dialogs.
+
 #define USE_TRANSIENT_POPUP           1 // Use wxPopupWindowTransient (preferred, if it works properly on platform)
-#define TRANSIENT_POPUPWIN_IS_PERFECT 0 // wxPopupTransientWindow works, its child can have focus, and common
+#define TRANSIENT_POPUPWIN_IS_PERFECT 1 // wxPopupTransientWindow works, its child can have focus, and common
                                         // native controls work on it like normal.
 #define POPUPWIN_IS_PERFECT           1 // Same, but for non-transient popup window.
 #define TEXTCTRL_TEXT_CENTERED        1 // 1 if text in textctrl is vertically centered
@@ -495,6 +499,11 @@ void wxComboPopup::OnDismiss()
 {
 }
 
+wxComboCtrl* wxComboPopup::GetComboCtrl() const
+{
+    return wxStaticCast(m_combo, wxComboCtrl);
+}
+
 wxSize wxComboPopup::GetAdjustedSize( int minWidth,
                                       int prefHeight,
                                       int WXUNUSED(maxHeight) )
@@ -573,6 +582,8 @@ private:
 
 BEGIN_EVENT_TABLE(wxComboBoxExtraInputHandler, wxEvtHandler)
     EVT_KEY_DOWN(wxComboBoxExtraInputHandler::OnKey)
+    EVT_KEY_UP(wxComboBoxExtraInputHandler::OnKey)
+    EVT_CHAR(wxComboBoxExtraInputHandler::OnKey)
     EVT_SET_FOCUS(wxComboBoxExtraInputHandler::OnFocus)
     EVT_KILL_FOCUS(wxComboBoxExtraInputHandler::OnFocus)
 END_EVENT_TABLE()
@@ -582,14 +593,17 @@ void wxComboBoxExtraInputHandler::OnKey(wxKeyEvent& event)
 {
     // Let the wxComboCtrl event handler have a go first.
     wxComboCtrlBase* combo = m_combo;
-    wxObject* prevObj = event.GetEventObject();
 
-    event.SetId(combo->GetId());
-    event.SetEventObject(combo);
-    combo->GetEventHandler()->ProcessEvent(event);
+    wxKeyEvent redirectedEvent(event);
+    redirectedEvent.SetId(combo->GetId());
+    redirectedEvent.SetEventObject(combo);
 
-    event.SetId(((wxWindow*)prevObj)->GetId());
-    event.SetEventObject(prevObj);
+    if ( !combo->GetEventHandler()->ProcessEvent(redirectedEvent) )
+    {
+        // Don't let TAB through to the text ctrl - looks ugly
+        if ( event.GetKeyCode() != WXK_TAB )
+            event.Skip();
+    }
 }
 
 void wxComboBoxExtraInputHandler::OnFocus(wxFocusEvent& event)
@@ -1652,7 +1666,8 @@ void wxComboCtrlBase::OnKeyEvent(wxKeyEvent& event)
     }
     else // no popup
     {
-        if ( HandleAsNavigationKey(event) )
+        if ( GetParent()->HasFlag(wxTAB_TRAVERSAL) &&
+             HandleAsNavigationKey(event) )
             return;
 
         if ( IsKeyPopupToggle(event) )
@@ -1833,7 +1848,10 @@ void wxComboCtrlBase::OnButtonClick()
 {
     // Derived classes can override this method for totally custom
     // popup action
-    ShowPopup();
+    if ( !IsPopupWindowState(Visible) )
+        ShowPopup();
+    else
+        HidePopup();
 }
 
 void wxComboCtrlBase::ShowPopup()