Questions about beginDragAutoRepeat

I’m having some trouble with Component::beginDragAutoRepeat() after updating the version of the tip I’m building against. I have a custom component that calls Compononent::beginDragAutoRepeat( ) in its mouseDrag callback. When I was building against a version of the tip from around September of last year, this worked fine. After a recent update the beginDragAutoRepeat( ) doesn’t appear to have any affect on the mouse dragging.

I see that there were a lot of changes to the internal mouse handling code in JUCE since the old version of the tip I was using. In the debugger I see that beginDragAutoRepeat( ) eventually calls MouseInputSource::triggerFakeMove( ), which pushes an asynchronous message onto the message thread. From that point on I’m a little lost as to what is going on. After the fake mouse move message has been posted, I don’t see any mouse events or mouse drag callbacks being fired. Component::internalMouseDrag( ) is never called, for example. When I step through the debugger using the older JUCE tip it’s very clear that
beginDragAutoRepeat( ) eventually calls internalMouseDrag( ), which calls my custom component’s mouseDrag callback and starts the cycle again.

I’m not sure how or where the mouse event should being generated in the new version of the JUCE tip, or if it is being generated at all. Any insight on how this is supposed to work would be greatly appreciated.

Yes, you’re right, it doesn’t seem to be working properly… Thanks, I’ll investigate that…


I just tried the fix you checked into the tip. Seems to be working fine now. Thanks!

Sorry, what fix is that? I am experiencing the same problem here!!


[quote=“fagedoc”]Sorry, what fix is that? I am experiencing the same problem here!!


…this thread is almost two years old - if you’ve got a similar problem, give me some more info based on the very latest code!

Well, as it happens to Dans, this function seems not to work for me. I have a MainComponent with a bunch of sub-components. All have a mouseDrag() callback, but only in the main component the Compononent::beginDragAutoRepeat( ) is called. Even if I use 1 ms as an interval, I don´t see any difference when I drag the mouse. Some of the events are simply not there, and the UI doesn’t update, as it does when I drag slowly.

Stepping with the debugger I saw that this method creates a MouseDragAutoRepeater that inherites from Timer. It triggers a fake move in the constructor, but afterwards it only calls a startTimer(). I didn’t get really deep in the problem, but it seems to me that the fake move is only called in the construction of the MouseDragAutoRepeater, and never again. Maybe I am wrong cause I am not familiar with the Timer classes in JUCE.

Well, if you have any idea, it would be really appreciated. Thanks in advance.

Well, that auto-repeat feature is used in lots of places, e.g. CodeEditor, ComboBox, and having a quick go of them now, it seems to work for me.

You have to call it on the component that actually receives the drag event, you know? Calling it on its parent is no use…

Actually, I have different behaviors in the sub-component than in the main one for the mouseDrag callback. The faster rate is needed in the main component. They share the same part of the screen, that is to say, the main components is a bigger layer over a bunch of subcomponents. Using breakpoints, I realized that first the sub-component mouseDrag callback is called and then the main component callback. Even if I use the beginDragAutoRepeat in both of them, I don´t notice a faster stream of mouseDrag events in my application. Sorry, but I don´t really get it at all.
If I use this method in both components, main and sub-component, the rate of the incoming mouseDrag events should be higher, and therefore, with fast mouse movements one should get more points in between, but it is not the case for me and I don´t understand really why.

Any help would be appreciated.


It causes fake mouse-drag events to be created when the mouse is stationary. While the mouse is moving, it has no effect at all.

The whole point is to keep a stream of events coming in, even when the user stops moving, not to somehow magically increase the resolution of all mouse events!

Ups. sorry then!! I misunderstood it totally. I thought that the fake mouse events were created while moving the mouse pointer, in order to interpolate very fast movements, which is an increment of the mouse resolution. It could a nice feature anyway.
Thank you for your answers!!!