Re: Programmatically created NSButton is drawn in the wrong position.
Based on what you are doing, setting the property to YES will get you closer to what your problem is. When this property is NO, you cannot accurately control the view’s frame. That being said, when are you verifying that the frame of the buttons is unchanged? Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business" > On Dec 15, 2020, at 3:49 AM, Eyal Redler via Cocoa-dev > wrote: > > setting translatesAutoresizingMaskIntoConstraints to yes makes the situation > worse. The buttons are drawn further away than their frames indicate. > > Eyal > >> On 15 Dec 2020, at 4:05, Ben Kennedy wrote: >> >> >>> On 14 Dec 2020, at 5:39 pm, Eyal Redler via Cocoa-dev >>> wrote: >>> >>> button = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 0, 0)]; >>> [button setTranslatesAutoresizingMaskIntoConstraints:NO]; >>> [button setBezelStyle:NSRoundedBezelStyle]; >>> [button setTitle:buttonTitle]; >>> [button sizeToFit]; >>> [button setFrameOrigin:NSMakePoint(position, 20)]; >> >> Since you're positioning the frames manually, you need to set >> setTranslatesAutoresizingMaskIntoConstraints = YES instead of NO. >> >> -ben >> > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > https://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40esoteritech.com > > This email sent to cocoa-...@esoteritech.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Programmatically created NSButton is drawn in the wrong position.
On Dec 15, 2020, at 04:49:19, Eyal Redler via Cocoa-dev wrote: > > setting translatesAutoresizingMaskIntoConstraints to yes makes the situation > worse. The buttons are drawn further away than their frames indicate. Are you using Xcode's Interface Debugger to inspect the entire view hierarchy and see what the frames of everything actually are, or are you just measuring pixels in a screenshot or something to determine that they're 6 points to the right? -- Steve Mills Drummer, Mac geek ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Programmatically created NSButton is drawn in the wrong position.
setting translatesAutoresizingMaskIntoConstraints to yes makes the situation worse. The buttons are drawn further away than their frames indicate. Eyal > On 15 Dec 2020, at 4:05, Ben Kennedy wrote: > > >> On 14 Dec 2020, at 5:39 pm, Eyal Redler via Cocoa-dev >> wrote: >> >> button = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 0, 0)]; >> [button setTranslatesAutoresizingMaskIntoConstraints:NO]; >> [button setBezelStyle:NSRoundedBezelStyle]; >> [button setTitle:buttonTitle]; >> [button sizeToFit]; >> [button setFrameOrigin:NSMakePoint(position, 20)]; > > Since you're positioning the frames manually, you need to set > setTranslatesAutoresizingMaskIntoConstraints = YES instead of NO. > > -ben > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Programmatically created NSButton is drawn in the wrong position.
> On 14 Dec 2020, at 5:39 pm, Eyal Redler via Cocoa-dev > wrote: > > button = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 0, 0)]; > [button setTranslatesAutoresizingMaskIntoConstraints:NO]; > [button setBezelStyle:NSRoundedBezelStyle]; > [button setTitle:buttonTitle]; > [button sizeToFit]; > [button setFrameOrigin:NSMakePoint(position, 20)]; Since you're positioning the frames manually, you need to set setTranslatesAutoresizingMaskIntoConstraints = YES instead of NO. -ben ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Programmatically created NSButton is drawn in the wrong position.
I'm configuring a view with some push buttons and other views programmatically and the buttons are drawn offset to the right. For example, the first button should be at 0,20 but it is drawn at 6,20. I checked that the buttons are not moved, the button frames remain the same, the buttons are just drawn 6 points to the right. Here's a screenshot: https://s3.amazonaws.com/mellel.outbox/button_woes.png Here's the code: NSView* _view = [_window contentView]; CGFloat position; position = 0; for (NSString* buttonTitle in @[@"button one",@"button two",@"button three"]) { NSButton* button; button = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 0, 0)]; [button setTranslatesAutoresizingMaskIntoConstraints:NO]; [button setBezelStyle:NSRoundedBezelStyle]; [button setTitle:buttonTitle]; [button sizeToFit]; [button setFrameOrigin:NSMakePoint(position, 20)]; [_view addSubview:button]; position += [button frame].size.width + 8; } Thanks in advance, Eyal Redler "If Uri Geller bends spoons with divine powers, then he's doing it the hard way." --James Randi www.eyalredler.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com