X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/974a12f86a2882b0999a441ce4ad07e0e2c4377c..a4609ab847819b47c996674420871f4514d50625:/src/common/combocmn.cpp diff --git a/src/common/combocmn.cpp b/src/common/combocmn.cpp index 6139dfc179..a633163d30 100644 --- a/src/common/combocmn.cpp +++ b/src/common/combocmn.cpp @@ -732,6 +732,8 @@ void wxComboCtrlBase::Init() m_toplevEvtHandler = (wxEvtHandler*) NULL; #endif + m_mainCtrlWnd = this; + m_heightPopup = -1; m_widthMinPopup = -1; m_anchorSide = 0; @@ -826,17 +828,14 @@ wxComboCtrlBase::CreateTextCtrl(int style, const wxValidator& validator) m_ignoreEvtText = 0; m_text = new wxTextCtrl(this, wxID_ANY, m_valueString, - wxDefaultPosition, wxDefaultSize, + wxDefaultPosition, wxSize(10,-1), style, validator); - - // This is required for some platforms (GTK+ atleast) - m_text->SetSizeHints(2,4); } } void wxComboCtrlBase::OnThemeChange() { - SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); + SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); } wxComboCtrlBase::~wxComboCtrlBase() @@ -1239,7 +1238,7 @@ void wxComboCtrlBase::PrepareBackground( wxDC&, const wxRect&, int ) const } #endif -void wxComboCtrlBase::DrawButton( wxDC& dc, const wxRect& rect, bool paintBg ) +void wxComboCtrlBase::DrawButton( wxDC& dc, const wxRect& rect, int paintBg ) { int drawState = m_btnState; @@ -1537,11 +1536,15 @@ void wxComboCtrlBase::OnKeyEvent(wxKeyEvent& event) if ( keycode == WXK_TAB ) { wxNavigationKeyEvent evt; + + wxWindow* mainCtrl = GetMainWindowOfCompositeControl(); + evt.SetFlags(wxNavigationKeyEvent::FromTab| (!event.ShiftDown() ? wxNavigationKeyEvent::IsForward : wxNavigationKeyEvent::IsBackward)); - evt.SetEventObject(this); - GetParent()->GetEventHandler()->AddPendingEvent(evt); + evt.SetEventObject(mainCtrl); + evt.SetCurrentFocus(mainCtrl); + mainCtrl->GetParent()->GetEventHandler()->AddPendingEvent(evt); return; } @@ -1574,8 +1577,11 @@ void wxComboCtrlBase::OnFocusEvent( wxFocusEvent& event ) { if ( event.GetEventType() == wxEVT_SET_FOCUS ) { - if ( m_text && m_text != ::wxWindow::FindFocus() ) - m_text->SetFocus(); +#ifndef __WXMAC__ + wxWindow* tc = GetTextCtrl(); + if ( tc && tc != DoFindFocus() ) + tc->SetFocus(); +#endif } Refresh(); @@ -1769,6 +1775,8 @@ void wxComboCtrlBase::ShowPopup() popup = m_popup; } + winPopup->Enable(); + wxASSERT( !m_popup || m_popup == popup ); // Consistency check. wxSize adjustedSize = m_popupInterface->GetAdjustedSize(widthPopup, @@ -1870,7 +1878,8 @@ void wxComboCtrlBase::ShowPopup() wxRect popupWinRect( popupX, popupY, szp.x, szp.y ); m_popup = popup; - if ( AnimateShow( popupWinRect, showFlags ) ) + if ( (m_iFlags & wxCC_IFLAG_DISABLE_POPUP_ANIM) || + AnimateShow( popupWinRect, showFlags ) ) { DoShowPopup( popupWinRect, showFlags ); } @@ -1914,20 +1923,13 @@ void wxComboCtrlBase::OnPopupDismiss() if ( IsPopupWindowState(Hidden) ) return; - // NB: Focus setting is really funny, atleast on wxMSW. First of all, - // we need to have SetFocus at the end. Otherwise wxTextCtrl may - // freeze until focus goes somewhere else. Second, wxTreeCtrl as - // popup, when dismissing, "steals" focus back to itself unless - // SetFocus is called also here, exactly before m_popupWinState - // is set to false. Which is truly weird since SetFocus is just - // wxWindowMSW method and does not call event handler or anything like - // that (ie. does not care about m_popupWinState). - - SetFocus(); - - // This should preferably be set before focus. + // This must be set before focus - otherwise there will be recursive + // OnPopupDismisses. m_popupWinState = Hidden; + //SetFocus(); + m_winPopup->Disable(); + // Inform popup control itself m_popupInterface->OnDismiss();