• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Invoking -setNeedsDisplay: Whacks frame of NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Invoking -setNeedsDisplay: Whacks frame of NSTextView


  • Subject: Invoking -setNeedsDisplay: Whacks frame of NSTextView
  • From: Jerry Krinock <email@hidden>
  • Date: Tue, 9 Sep 2008 13:54:50 -0700

Just when I think I've seen everything....

Code:
NSLog(@"myTextView is a %@", [myTextView class]) ;
NSLog(@"Before, its frame is: %@", NSStringFromRect([myTextView frame])) ;
[myTextView setNeedsDisplay:YES] ;
NSLog(@" After, its frame is: %@", NSStringFromRect([myTextView frame])) ;


Console Output:
    myTextView is a NSTextView
    Before, its frame is: {{17, 63}, {250, 75}}
     After, its frame is: {{17, 123}, {250, 45}}

Why did -setNeedsDisplay: move my text view's y-origin up by 60 and reduce its height by 30?

A possible answer [1] is that Cocoa does "not support" views overlapping one another. Indeed, there are are sibling views that may be overlapping at this point.

The code above is part of a method which "lays out" a window which I create programatically. It is an enhanced NSAlert that, besides having an icon, some text and three buttons, can have a progress bar, editable text fields with labels, pulldown menus, checkbox, etc. I use it for all of my alerts, errors, and more. However, since the presence and size of all these subviews changes dynamically, I have this method which, just prior to display, scans horizontally and then vertically and sets all the frames. It's a handy class, and cool when the layout works, which it does about 99% of the time. I inserted that -setNeedsDisplay while troubleshooting one of the 1% cases and WHOA the frame got whacked. I suspect that the same frame-whacking mechanism is causing the actual problem I need to solve.

Also, I wonder if this is might be related to -[NSTextView setNeedsDisplayInRect:avoidAdditionalLayout:]. But the documentation seems to indicate that "layout" in this case has to do with word positioning and line wrapping.

Nowhere can I find any documentation that setNeedsDisplay: should whack an NSView's frame. This is all in Leopard, so it's not some old long-fixed bug.

Jerry

[1] http://www.cocoabuilder.com/archive/message/cocoa/2006/10/17/172951


_______________________________________________

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


  • Prev by Date: Re: NSTableView works in 10.5 but not in 10.4
  • Next by Date: Re: While we're on the subject of DMG's for software distribution...
  • Previous by thread: Re: No action msg after NSPathControl "Choose"
  • Next by thread: Core Data and Garbage Collection
  • Index(es):
    • Date
    • Thread