Strange NSScroller sizing behaviour
Strange NSScroller sizing behaviour
- Subject: Strange NSScroller sizing behaviour
- From: Jo Meder <email@hidden>
- Date: Thu, 29 Apr 2010 23:59:43 +1200
Hi,
I'm using NSScrollers directly, e.g. not in an NSScrollView. Using 10.6.3 (haven't checked anything else mind you) I'm seeing some strange behaviour when I try and resize them. I have code similar to the autosizing stuff in Cocoa/IB which, for example, resizes controls as a window resizes. I noticed that NSScrollers didn't seem to be resizing properly and were falling behind the size they should be. This is the function I use to set the width of a control:
void UCMacControlImp::SetWidth( const SInt32 theWidth )
{
NSRect frame = [m_nativeControl frame];
[[m_nativeControl superview] setNeedsDisplayInRect:[m_nativeControl frame]];
frame.size.width = floor( ( CGFloat )theWidth );
[m_nativeControl setFrame:frame];
[m_nativeControl setNeedsDisplay:YES];
return;
}
What I noticed in the debugger was that the frame of the NSScroller occasionally wasn't changing to what I set it to. For example if theWidth was 586 and the frame width at the time SetWidth() is called is 585 then after the setFrame: message the width of the frame would still be 585, not 586. This doesn't happen all the time, just occasionally, but it's enough for the width to get out of sync with what it should be. When the correct thing does happen I see the values update as expected in the debugger.
In my test app I have an NSButton in the same window but that stays perfectly in sync as it's resized. I also haven't noticed problems with any other views, which I use plenty of, it just seems to be NSScrollers. The problem occurs in both 32 and 64 bit builds.
Originally I was using setFrameSize: but that also had problems.
Does anyone have any ideas about what might be going on?
Regards,
Jo Meder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden