]> 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 89367d068b842d6da7e118bc1640dd2be119fe84..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
@@ -461,7 +465,7 @@ void wxComboPopupWindowEvtHandler::OnKeyEvent( wxKeyEvent& event )
     wxWindowList children = m_combo->GetPopupWindow()->GetChildren();
     wxWindowList::iterator node = children.begin();
     wxWindow* child = (wxWindow*)*node;
-    child->AddPendingEvent(event);
+    child->GetEventHandler()->AddPendingEvent(event);
 }
 
 #if USES_WXDIALOG
@@ -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)
@@ -1177,7 +1191,7 @@ bool wxComboCtrlBase::Enable(bool enable)
         m_btn->Enable(enable);
     if ( m_text )
         m_text->Enable(enable);
-        
+
     Refresh();
 
     return true;
@@ -1648,11 +1662,12 @@ void wxComboCtrlBase::OnKeyEvent(wxKeyEvent& event)
     if ( IsPopupShown() )
     {
         // pass it to the popped up control
-        GetPopupControl()->GetControl()->AddPendingEvent(event);
+        GetPopupControl()->GetControl()->GetEventHandler()->AddPendingEvent(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()