Positioning issues with NSViewComponent


#1

I have a NSTextField as the view in a NSViewComponent which is added to a Component (i.e. Component->NSViewComponent->NSTextField)

When the main window resizes I need to move the Component for correct GUI alignment (aligned top right in main window), but the NSTextField moves around a bit (i.e. not staying within the Component). Specifically when the main window is resized in height.

Any idea what might cause this?


#2

Perhaps some int/float rounding issue? NSRects are all float coords, yes? Or are you talking about major movement? (Although it could still be related.)


#3

Oh yeah, major movement. If I resize with +100 pixels in height, the NSTextField might get 100 pixels from where it should be. Cocoa has window position 0,0 bottom left, whereas Carbon had 0,0 at top left. Don’t know if that has anything to do with it…


#4

sounds like a resize issue I was having in AUs


#5

yep, that’ll be it.


#6

Ok then, is it something I’ve done wrong or a bug in the NSView wrapper component? I haven’t done much more than plug the NSTextField into the NSViewComponent, pretty much as I’d have with any other component…


#7

Try…

textField=[[NSTextField alloc]initWithFrame:NSMakeRect(0,0,100,100)];
setView(textField);
[textField setAutoresizingMask:NSViewMinYMargin];

?

Justin


#8

Thnx Justin, that did the trick! :slight_smile: