Re: Strange NSScroller sizing behaviour
Re: Strange NSScroller sizing behaviour
- Subject: Re: Strange NSScroller sizing behaviour
- From: Bill Appleton <email@hidden>
- Date: Thu, 29 Apr 2010 12:08:44 -0700
hi Jo,
i am also working with NSScroller directly
i have two types of windows
in one type, the vertical bar appears and the horizontal bar is missing
in the other type, the opposite situation occurs
i am sure they are set to the right bounds, etc. and visible
have you looked at NSControl
calcSize and sizeToFit?
thx
bill appleton
On Thu, Apr 29, 2010 at 4:59 AM, Jo Meder <email@hidden> wrote:
> 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
>
_______________________________________________
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