No "MouseUp" on "Telerik.WiControls.UI.radTrackBarElement"

4 posts, 0 answers
  1. Vishal
    Vishal avatar
    5 posts
    Member since:
    May 2018

    Posted 10 Jul 2018 Link to this post

    Hello Support,

    I have implemented a Telerik.WiControls.UI.radTrackBarElement on which a number of actions are performed after the value has changed/changes. 

    Now, the value_changed event is fired even if I have my mouse down. Is there a possibility that the actual value changes after I release my mouse button so the trackbar responds much quicker.
  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3379 posts

    Posted 11 Jul 2018 Link to this post

    Hello, Vishal,    

    By design, the thumb is moved when handling MouseDown. As a result, the value is changed. This logic is at a location that is too deep in the RadTrackBar functionality for any customization to have effect on it. However, you can handle the MouseUp and ValueChanged event and achieve the desired functionality. Here is a sample code snippet. Note that this is just a sample approach and it may not cover all possible cases. Feel free to modify it in a way which suits your requirement best.
    public RadForm1()
    {
        InitializeComponent();
     
        this.radTrackBar1.MouseUp += radTrackBar1_MouseUp;
        this.radTrackBar1.ValueChanged += radTrackBar1_ValueChanged;
    }
     
    float lastValue = 0;
    float previousValue = 0;
     
    private void radTrackBar1_ValueChanged(object sender, EventArgs e)
    {
        if (this.radTrackBar1.Value != previousValue)
        {
            lastValue = this.radTrackBar1.Value;
            this.radTrackBar1.Value = previousValue;
        }
    }
     
    private void radTrackBar1_MouseUp(object sender, MouseEventArgs e)
    {
        previousValue = lastValue;
        this.radTrackBar1.Value = lastValue;
    }

    I hope this information helps. If you have any additional questions, please let me know.  
     
    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Vishal
    Vishal avatar
    5 posts
    Member since:
    May 2018

    Posted 11 Jul 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Hi Dess,

    Thanks for your response on this, But if you see my question again the functionality i want to achieve will use "Telerik.WinControls.UI.radTrackBarElement". radTrackBar and radTrackbarElement(component of RadRibbon) are different things and i can not use one in another's position.

    Kindly let me know if my understanding is wrong or what can be done to achieve "Mouse Up" in Telerik.WinControls.UI.radTrackBarElement

     

    Regards

    Vishal Kashyap

  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3379 posts

    Posted 12 Jul 2018 Link to this post

    Hello, Vishal,    

    I would like to note that RadTrackBar contains a RadTrackBarElement in its internal elements hierarchy. You can handle the RadTrackBarElement.ValueChnaged event to manipulate the value. Then, subscribe to the RadTrackBarElement.BodyElement.MouseUp to update the correct value. Here is the modified code snippet relevant for the RadTrackBarElement hosted in RadRibbonBar:

    public RadForm1()
    {
        InitializeComponent();
     
        this.radTrackBarElement1.BodyElement.MouseUp += radTrackBarElement1_MouseUp;
        this.radTrackBarElement1.ValueChanged += radTrackBarElement1_ValueChanged;
    }
     
    private void radTrackBarElement1_ValueChanged(object sender, EventArgs e)
    {
        if (this.radTrackBarElement1.Value != previousValue)
        {
            lastValue = this.radTrackBarElement1.Value;
            this.radTrackBarElement1.Value = previousValue;
        }
    }
     
    private void radTrackBarElement1_MouseUp(object sender, MouseEventArgs e)
    {
        previousValue = lastValue;
        this.radTrackBarElement1.Value = lastValue;
    }
     
    float lastValue = 0;
    float previousValue = 0;

    I hope this information helps. If you have any additional questions, please let me know.  
     
    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top