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
This commit is contained in:
Vadim Zeitlin 2005-05-31 15:33:43 +00:00
parent fa1af598d6
commit 3c96417a09
4 changed files with 25 additions and 7 deletions

View File

@ -39,6 +39,7 @@ wxMSW:
- Winelib compilation now works. - Winelib compilation now works.
- When converting a wxIcon to a bitmap check if the icon has an alpha - When converting a wxIcon to a bitmap check if the icon has an alpha
channel and set the bitmap to use it. channel and set the bitmap to use it.
- wxSlider now also sends wxEVT_SCROLL_CHANGED when using mouse wheel
wxGTK: wxGTK:

View File

@ -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). cases the {\tt EVT\_SCROLL\_THUMBRELEASE} event does not happen).
In short, the {\tt EVT\_SCROLL\_CHANGED} event is triggered when scrolling/ In short, the {\tt EVT\_SCROLL\_CHANGED} event is triggered when scrolling/
moving has finished. The only exception (unfortunately) is that changing the moving has finished independently of the way it had started. Please see the
thumb position using the mousewheel does give a {\tt EVT\_SCROLL\_THUMBRELEASE} widgets sample ("Slider" page) to see the difference between {\tt
event but NOT an {\tt EVT\_SCROLL\_CHANGED} event. EVT\_SCROLL\_THUMBRELEASE} and {\tt EVT\_SCROLL\_CHANGED} in action.
Please see the widgets sample ("Slider" page) to see the difference
between {\tt EVT\_SCROLL\_THUMBRELEASE} and {\tt EVT\_SCROLL\_CHANGED} in action.

View File

@ -130,6 +130,9 @@ protected:
int m_lineSize; int m_lineSize;
int m_tickFreq; 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) DECLARE_DYNAMIC_CLASS_NO_COPY(wxSlider)
}; };

View File

@ -149,6 +149,8 @@ void wxSlider::Init()
m_rangeMax = 0; m_rangeMax = 0;
m_rangeMin = 0; m_rangeMin = 0;
m_tickFreq = 0; m_tickFreq = 0;
m_isDragging = false;
} }
bool bool
@ -328,10 +330,25 @@ bool wxSlider::MSWOnScroll(int WXUNUSED(orientation),
case SB_THUMBTRACK: case SB_THUMBTRACK:
scrollEvent = wxEVT_SCROLL_THUMBTRACK; scrollEvent = wxEVT_SCROLL_THUMBTRACK;
m_isDragging = true;
break; break;
case SB_THUMBPOSITION: 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; break;
case SB_ENDSCROLL: case SB_ENDSCROLL: