Hello,

I am trying to place an InvalidData icon next to offending input elements 
(popup menus, text fields, etc). I calculate the position of the new 
NSImageVIew based on the frame of the UI element. Keep it's vertical placement, 
and shift the icon to the left if it, plus a small constant spacing amount, and 
make square.

    NSView *aview = theOffendingNSTextView;

    NSView *superView = [aview superview];
        
    NSRect oldframe = [aview frame];
        
    NSRect newFrame = NSMakeRect(
            oldframe.origin.x + oldframe.size.width + 26,
                                 oldframe.origin.y,
                                 oldframe.size.height,
                                 oldframe.size.height);

    NSImageView *img = [[NSImageView alloc] initWithFrame:newFrame];
    [img setImage:[NSImage imageNamed:@"NSInvalidDataFreestandingTemplate"]];

    [superView addSubview:img];

This works the horizontal positioning just fine, but the vertical placement is 
always to far down the parent view (superView).

Interestingly, if I use IB to place an icon next to the popup field, XCode 
tells me its coordinates would exactly match the ones I calculate. Yet using 
them to initWithFrame results in the icon being too far down.

If I trial-and-error to find a frame value which places the icon properly, it 
ends up being 170 units larger than what I expect it to be (both from the above 
calculation and seeing where it would be if I placed in XCode).

I have a draft email saved with much more details (how I'm placing the view, 
and concrete values for various frames, etc) but I thought first I'd check to 
see if there's anything obviously wrong I'm doing. Is there?

I suppose I could always fall back to placing the invalid icons manually, and 
bind their visible/hidden attribute to the validation results, but that seems 
overkill. Is there a "more proper" way to achieve my goals that what I'm 
attempting?

Thanks,
DavidM_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to