X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f0985cf4eaec9bf271215dda5ff6795a7dfae9b5..ce457f1245754243f17b4efde9ec773a8b3c3067:/src/common/popupcmn.cpp diff --git a/src/common/popupcmn.cpp b/src/common/popupcmn.cpp index 143dff2635..57ba86c0a0 100644 --- a/src/common/popupcmn.cpp +++ b/src/common/popupcmn.cpp @@ -34,6 +34,8 @@ #include "wx/log.h" #endif //WX_PRECOMP +#include "wx/recguard.h" + #ifdef __WXUNIVERSAL__ #include "wx/univ/renderer.h" #include "wx/scrolbar.h" @@ -149,7 +151,18 @@ void wxPopupWindowBase::Position(const wxPoint& ptOrigin, } // now check left/right too - wxCoord x = ptOrigin.x + size.x; + wxCoord x = ptOrigin.x; + + if ( wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft ) + { + // shift the window to the left instead of the right. + x -= size.x; + x -= sizeSelf.x; // also shift it by window width. + } + else + x += size.x; + + if ( x + sizeSelf.x > sizeScreen.x ) { // check if there is enough space to the left @@ -561,6 +574,16 @@ void wxPopupFocusHandler::OnKillFocus(wxFocusEvent& event) void wxPopupFocusHandler::OnKeyDown(wxKeyEvent& event) { + // we can be associated with the popup itself in which case we should avoid + // infinite recursion + static int s_inside; + wxRecursionGuard guard(s_inside); + if ( guard.IsInside() ) + { + event.Skip(); + return; + } + // let the window have it first, it might process the keys if ( !m_popup->GetEventHandler()->ProcessEvent(event) ) {