Real Software Forums
http://forums.realsoftware.com/

Timer animations stop during user input
http://forums.realsoftware.com/viewtopic.php?f=4&t=43196
Page 1 of 1

Author:  rjriv [ Sat Mar 17, 2012 3:20 pm ]
Post subject:  Timer animations stop during user input

Hello,

I hope this was the right board to post this question on; it seemed like the most likely group that would have dealt with this before!

I am new to RB but old to VB, so it mostly makes sense, but on a Mac running RS2011 r4.3, I just can't seem to make simple timer animations continue during any user input in any of my application windows such as resizing a window, moving a window, clicking on a button, etc...

All I was trying to do was move a canvas object back and forth on a window and eventually control some properties about it from another window while it continued to move (color, speed, etc...).

I have tried controlling the animation from a timer control and from a timer object created in code, and in both cases, the timer ceases to fire during these events (such as clicking on the title bar and leaving the mouse down). I have not tried anything with a thread because the documentation says you should still use a timer to get the results from the thread to control the UI, so it seems I would be right back where I started.

Is this even possible in RB on a Mac?

Thank you,

Rob

Author:  DaveS [ Sat Mar 17, 2012 3:47 pm ]
Post subject:  Re: Timer animations stop during user input

keyword here : THREADS

If you have the timer/animation and user input processing all in the main thread (which is where they all are by default).... The program can only do one thing at a time...... and User Keyboard input has a much higher priority that timer interrupts, so when there is keyboard/mouse activity, all timers in the main thread are suspended until free cycles become available again.

Multi-thread your application (read the manuals), and your keyboard input is on one thread, and timers on another.

Author:  timhare [ Sat Mar 17, 2012 3:59 pm ]
Post subject:  Re: Timer animations stop during user input

I'm afraid threads won't help here. A timer is the correct choice, but there are certain actions like clicking a menu that stall/steal the event loop under Carbon. I believe Cocoa resolves this, but I'm not certain. You might try compiling for Cocoa.

Author:  rjriv [ Sat Mar 17, 2012 4:23 pm ]
Post subject:  Re: Timer animations stop during user input

Thank you for the Cocoa tip! I had not thought to try anything like that.

It mostly works...if you resize the window with the actual animation in it and leave the mouse down without moving it, the timer will completely stop firing still. But if you keep moving the mouse it just interrupts the timer. You CAN resize another window in the application, though, as well as interact with controls, so this is a great start, thank you!

In reference to the threads is it really possible in RB to handle the mouse input for a window in a completely separate thread? I think I have a ways to go before I could try something like that...!

Thank you for the help,

Rob

Author:  timhare [ Sat Mar 17, 2012 4:31 pm ]
Post subject:  Re: Timer animations stop during user input

rjriv wrote:
In reference to the threads is it really possible in RB to handle the mouse input for a window in a completely separate thread?

No. I think what Dave was alluding to was using the thread as a "timer". Otherwise, you cannot separate user interaction from a normal timer. Both are processed by the event loop, which is in the main thread.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/