I want a toolbar button that acts as a fast forward button, calling a function every X milliseconds as long as the button is pressed. I tried the obvious way: set a “playbackSpeed” variable on mouse down, zero it on mouse up. But seems buttons eat their MouseDownEvents so this failed:
The button:
var buttonNext = root.Q<ToolbarButton>("button-next");
Mouse up event is fired:
buttonNext.RegisterCallback<MouseUpEvent>((evt) =>
{
Debug.Log("I'm called");
});
Mouse down, never:
buttonNext.RegisterCallback<MouseDownEvent>((evt) =>
{
Debug.Log("I'm never called");
});
Then I got wind of something called “Clickable”, which has a delay and interval on its constructor. It’s part or something called “Manipulators”, that isn’t anywhere in the documentation (as usual). After fumbling through the reference source code, I still can’t figure out how to get them to work (if they even do):
I tried this:
buttonNext.clickable = new Clickable(
() => {
Debug.Log("I'm never called either");
}, 0, 20);
And this:
var clickableMess = new Clickable(
() => {
Debug.Log("I too, will never be called");
},
0, 20);
clickableMess.activators.Add(new ManipulatorActivationFilter() { button = MouseButton.LeftMouse, clickCount = 1 });
buttonNext.AddManipulator(clickableMess);
Is this even possible at all, or should I begin rolling my own buttons from scratch too?