fabricelacharme / ColorSlider

ColorSlider is a trackbar control written in C#
MIT License
18 stars 5 forks source link

Mouse wheel values not returned to scroll event #3

Open tomb18 opened 5 years ago

tomb18 commented 5 years ago

Hi, There is an issue with using a mouse wheel and the scroll event. The mouse wheel changes do not raise the scroll event as in a standard track bar. They do work with the value changed event. However, the value changed event is not a good choice since any changes to the trackbar will result in an event. For example, the slider positions in my application are established by polling a radio for the values of particular functions. For example, I may poll the radio for the audio gain level. I then set the position of the audio gain slider. This is fine if you use the scroll event. On the other hand, if you use value changed you end in a loop where the control is updated, then a value changed event is generated and back and forth. Where do I need to change this in the slider source? I have been unable to locate where this should be done? Thanks, Tom

blackholeearth commented 1 week ago

//to match winforms behavour scroll , you need to add 2 events.

form1_load()
{
    trackBar1.Scroll += trackBar1_Scroll;
    trackBar1.MouseWheel += trackBar1_Scroll;   /*  <----notice  */
}

private void trackBar1_Scroll(object sender, EventArgs e)
{
       var scrollmsg ="you have scrolled via msclick or key"
       var whellmsg ="you have scrolled via wheel"
}