Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Double clicking UIToolkit Buttons

Discussion in 'UI Toolkit' started by Kan15hkSMT, May 28, 2020.

  1. Kan15hkSMT

    Kan15hkSMT

    Joined:
    Nov 13, 2019
    Posts:
    37
    Is there a built in way to detect if a UIToolkit Button has been double clicked?
     
  2. uMathieu

    uMathieu

    Unity Technologies

    Joined:
    Jun 6, 2017
    Posts:
    396
    You can register to MouseDownEvent and look at the mouseEvent.clickCount, let me know if that helps
     
    Catsoft-Studios likes this.
  3. Deleted User

    Deleted User

    Guest

    When I register the callback like this

    Code (CSharp):
    1. VisualElement.RegisterCallback<MouseDownEvent>(OnMouseDown);
    and log the clickCount like this

    Code (CSharp):
    1. private void OnMouseDown(MouseDownEvent evt)
    2. {
    3.     Debug.Log(evt.clickCount);
    4. }
    then no matter how often I click in succession or how quickly I do it, the log output is always "1". What am I doing wrong?
     
  4. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    808
  5. ChGuidi

    ChGuidi

    Joined:
    Dec 28, 2021
    Posts:
    111
    Hi, I have the same issue, I'm on version 2022.3.11. Should this be fixed?
     
    niuage likes this.
  6. niuage

    niuage

    Joined:
    Nov 17, 2019
    Posts:
    122
    Same issue on 2022.3.15f1.