X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e2495f725c6686edbcb1682ed957117ad68a6249..ed8f0b067521d3b86db3a73c5843aea6f3b13605:/src/generic/scrlwing.cpp diff --git a/src/generic/scrlwing.cpp b/src/generic/scrlwing.cpp index e8154d1559..7dcd4ba055 100644 --- a/src/generic/scrlwing.cpp +++ b/src/generic/scrlwing.cpp @@ -203,8 +203,13 @@ bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event) // user code defined OnPaint() in the derived class) m_hasDrawnWindow = true; - // pass it on to the real handler - bool processed = wxEvtHandler::ProcessEvent(event); + // Pass it on to the real handler: notice that we must not call + // ProcessEvent() on this object itself as it wouldn't pass it to the next + // handler (i.e. the real window) if we're called from a previous handler + // (as indicated by "process here only" flag being set) and we do want to + // execute the handler defined in the window we're associated with right + // now, without waiting until TryAfter() is called from wxEvtHandler. + bool processed = m_nextHandler->ProcessEvent(event); // always process the size events ourselves, even if the user code handles // them as well, as we need to AdjustScrollbars() @@ -298,8 +303,18 @@ bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event) } } - if ( processed ) - event.Skip(wasSkipped); + event.Skip(wasSkipped); + + // We called ProcessEvent() on the next handler, meaning that we explicitly + // worked around the request to process the event in this handler only. As + // explained above, this is unfortunately really necessary but the trouble + // is that the event will continue to be post-processed by the previous + // handler resulting in duplicate calls to event handlers. Call the special + // function below to prevent this from happening, base class DoTryChain() + // will check for it and behave accordingly. + // + // And if we're not called from DoTryChain(), this won't do anything anyhow. + event.DidntHonourProcessOnlyIn(); return processed; } @@ -328,6 +343,8 @@ wxScrollHelperBase::wxScrollHelperBase(wxWindow *win) m_xScrollingEnabled = m_yScrollingEnabled = true; + m_kbdScrollingEnabled = true; + m_scaleX = m_scaleY = 1.0; #if wxUSE_MOUSEWHEEL @@ -829,6 +846,12 @@ void wxScrollHelperBase::HandleOnPaint(wxPaintEvent& WXUNUSED(event)) // this they always have the priority void wxScrollHelperBase::HandleOnChar(wxKeyEvent& event) { + if ( !m_kbdScrollingEnabled ) + { + event.Skip(); + return; + } + // prepare the event this key press maps to wxScrollWinEvent newEvent; @@ -911,11 +934,7 @@ bool wxScrollHelperBase::SendAutoScrollEvents(wxScrollWinEvent& event) const void wxScrollHelperBase::StopAutoScrolling() { #if wxUSE_TIMER - if ( m_timerAutoScroll ) - { - delete m_timerAutoScroll; - m_timerAutoScroll = NULL; - } + wxDELETE(m_timerAutoScroll); #endif }