From 3c96417a099e8c99e9635a9aba2ce05b8f5572f7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 31 May 2005 15:33:43 +0000 Subject: [PATCH] send wxEVT_SCROLL_CHANGED when using mouse wheel as well git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34458 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + docs/latex/wx/scrolevt.inc | 9 +++------ include/wx/msw/slider95.h | 3 +++ src/msw/slider95.cpp | 19 ++++++++++++++++++- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index c0942dc430..bb52f0cc4a 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -39,6 +39,7 @@ wxMSW: - Winelib compilation now works. - When converting a wxIcon to a bitmap check if the icon has an alpha channel and set the bitmap to use it. +- wxSlider now also sends wxEVT_SCROLL_CHANGED when using mouse wheel wxGTK: diff --git a/docs/latex/wx/scrolevt.inc b/docs/latex/wx/scrolevt.inc index 69ccf6af40..a8849ebc86 100644 --- a/docs/latex/wx/scrolevt.inc +++ b/docs/latex/wx/scrolevt.inc @@ -46,10 +46,7 @@ change the thumb position, and when clicking next to the thumb (In all these cases the {\tt EVT\_SCROLL\_THUMBRELEASE} event does not happen). In short, the {\tt EVT\_SCROLL\_CHANGED} event is triggered when scrolling/ -moving has finished. The only exception (unfortunately) is that changing the -thumb position using the mousewheel does give a {\tt EVT\_SCROLL\_THUMBRELEASE} -event but NOT an {\tt EVT\_SCROLL\_CHANGED} event. - -Please see the widgets sample ("Slider" page) to see the difference -between {\tt EVT\_SCROLL\_THUMBRELEASE} and {\tt EVT\_SCROLL\_CHANGED} in action. +moving has finished independently of the way it had started. Please see the +widgets sample ("Slider" page) to see the difference between {\tt +EVT\_SCROLL\_THUMBRELEASE} and {\tt EVT\_SCROLL\_CHANGED} in action. diff --git a/include/wx/msw/slider95.h b/include/wx/msw/slider95.h index 68033d6c79..fbe92a43df 100644 --- a/include/wx/msw/slider95.h +++ b/include/wx/msw/slider95.h @@ -130,6 +130,9 @@ protected: int m_lineSize; int m_tickFreq; + // flag needed to detect whether we're getting THUMBRELEASE event because + // of dragging the thumb or scrolling the mouse wheel + bool m_isDragging; DECLARE_DYNAMIC_CLASS_NO_COPY(wxSlider) }; diff --git a/src/msw/slider95.cpp b/src/msw/slider95.cpp index b53b0d871b..da83a733f6 100644 --- a/src/msw/slider95.cpp +++ b/src/msw/slider95.cpp @@ -149,6 +149,8 @@ void wxSlider::Init() m_rangeMax = 0; m_rangeMin = 0; m_tickFreq = 0; + + m_isDragging = false; } bool @@ -328,10 +330,25 @@ bool wxSlider::MSWOnScroll(int WXUNUSED(orientation), case SB_THUMBTRACK: scrollEvent = wxEVT_SCROLL_THUMBTRACK; + m_isDragging = true; break; case SB_THUMBPOSITION: - scrollEvent = wxEVT_SCROLL_THUMBRELEASE; + if ( m_isDragging ) + { + scrollEvent = wxEVT_SCROLL_THUMBRELEASE; + m_isDragging = false; + } + else + { + // this seems to only happen when the mouse wheel is used: in + // this case, as it might be unexpected to get THUMBRELEASE + // without preceding THUMBTRACKs, we don't generate it at all + // but generate CHANGED event because the control itself does + // not send us SB_ENDSCROLL for whatever reason when mouse + // wheel is used + scrollEvent = wxEVT_SCROLL_CHANGED; + } break; case SB_ENDSCROLL: