Search code examples
c++sliderwxwidgets

gain control by wxSlider


I am using wxSlider to adjust gain in my Windows C++ application. Bind() function code:

sliderAmp->Bind(wxEVT_COMMAND_SLIDER_UPDATED, wxScrollEventHandler(App::OnSliderAmpChanged), this);

With such an implementation, the effect of "bounce" of values appears, i.e. multiple identical values may appear.

How to change the code so that the gain control is more reasonable?


Solution

  • Notice that wxEVT_COMMAND_SLIDER_UPDATED is an alias of wxEVT_SLIDER, and in the latest versions only the latter remained documented.

    I think you need to handle only wxEVT_SCROLL_CHANGED. Unfortunately that is documented to be MSW only.

    For non-MSW, you might get away with handling wxEVT_SCROLL_THUMBRELEASE. In case you want keyboard support you might need to add handling of other events. See wxSlider Class Reference too.