Slider updated by timer - interrupt with mouse click?

Hi Guys,

Newbie here. Like Thanos, I’m cursed with knowledge:) Did quite a lot of basic programming back in the day (68000 - yes, I’m that old) so have some basic idea of how to do things, but not necessarily how to achieve them within Xojo.

So, I’m building a little music player based on AV Foundation. I can play a file, get its current position and I’m linking that to a slider that updates its position via a timer - then a gui refresh via a Thread.
So far, so good.

However, like in Spotify, I’d like the user to be able to move the slider to another position.
Currently, when you click it it will get interrupted by the timer and moved by itself.

So I want to interrupt the slider on a mouse down, allow the user to move it around, get the new position, and then continue playback (and the slider update) once the mouse Is up/released.

my thoughts so far:
-a Boolean for an ‘is mouse pressed’ flag, for when the user presses the mouse in the slider area
-the slider in the timer only updates itself when this boolean is false

My question: where do I do this? In the slider itself, on a mouse down event?

1 Like

You can create a subclass for the slider that has a private boolean and a public method.
https://docs.xojo.com/UserGuide:Subclassing_Examples

In the slider’s MouseDown set the boolean to False, and in MouseUp update the timer, and Set the boolean to True.

Use the timer to call the public method on the custom slider. In the method, only update the slider’s position if its private boolean is set to True.

1 Like

Thank you for your help, going to give that a go!

1 Like
Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.