Window live resize and timers

Discussion in 'Mac Programming' started by rossipoo, May 3, 2010.

  1. rossipoo macrumors regular

    Jun 7, 2009
    How can I keep my timers in the runloop firing while the window is being resized? timers in the default run loop will not fire during resize.
  2. kpua macrumors 6502

    Jul 25, 2006
    Did you try adding the timer to the runloop with NSEventTrackingRunLoopMode or NSRunLoopCommonModes?
  3. rossipoo thread starter macrumors regular

    Jun 7, 2009
    That could be it, I will try that. I've never used any others beside the default before.
  4. rossipoo thread starter macrumors regular

    Jun 7, 2009
    I solved the issue using NSRunLoopCommonModes.

    I was using the timer to update the content of a view. It changed an ivar and then set the needsDisplay attribute. Unfortunately, the needsDisplay attribute seems to only used by the mainRunLoop. During a live resize, it is never checked. My view content would only redraw when the frame of the view changed; if I just held the resize-corner in one place, it would never update.

    I changed the timer to instead call display rather than setNeedsDisplay, which forces a redraw without waiting to return to the runloop.

Share This Page