X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/76fa9e023cdc89c86f9d69c48410c29a69e49827..82c126e50158efee5a1f46e1200be380c5199f8d:/src/common/popupcmn.cpp diff --git a/src/common/popupcmn.cpp b/src/common/popupcmn.cpp index 395374ad66..57ba86c0a0 100644 --- a/src/common/popupcmn.cpp +++ b/src/common/popupcmn.cpp @@ -34,11 +34,11 @@ #include "wx/log.h" #endif //WX_PRECOMP +#include "wx/recguard.h" + #ifdef __WXUNIVERSAL__ #include "wx/univ/renderer.h" -#if wxUSE_SCROLLBAR #include "wx/scrolbar.h" -#endif #endif // __WXUNIVERSAL__ #ifdef __WXGTK__ @@ -151,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 @@ -563,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) ) {