Changeset 28248


Ignore:
Timestamp:
Aug 26, 2007, 9:19:44 AM (13 years ago)
Author:
rhwood@…
Message:

Use minSizeForContent method to determine size instead of mucking with selection.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • users/rhwood/Pallet/IFVerticallyExpandingTextField.m

    r26306 r28248  
    6767                      surroundingView: (NSView *)originView;
    6868- (void) restoreAutoresizeMasks;
     69- (NSSize)minSizeForContent;
    6970
    7071@end
     
    122123     
    123124      // Set cursor to end, breaking the selection
    124       [fieldEditor setSelectedRange: NSMakeRange([[self stringValue] length], 0)];
     125      //[fieldEditor setSelectedRange: NSMakeRange([[self stringValue] length], 0)];
    125126   }
    126127   
     
    137138
    138139/* Private methods */
     140- (NSSize)minSizeForContent {
     141        NSRect frame = [self frame];
     142        NSRect newf = frame;
     143        NSTextView* editor = nil;
     144        if ((editor = (NSTextView*)[self currentEditor])) {
     145                newf = [[editor layoutManager] usedRectForTextContainer:[editor textContainer]];
     146                newf.size.height += frame.size.height-[[self cell] drawingRectForBounds:frame].size.height;
     147        } else {
     148                newf.size.height = HUGE_VALF;
     149                newf.size = [[self cell] cellSizeForBounds:newf];
     150        }
     151        frame.size.height = newf.size.height;
     152        return frame.size;
     153}
    139154
    140155- (void) autosizeHeight: (NSTextView *)fieldEditor {
     
    147162      newHeight = 0;
    148163   else
    149       newHeight = [[fieldEditor layoutManager] usedRectForTextContainer:
    150          [fieldEditor textContainer]].size.height + IFVerticalPadding;
     164      newHeight = [self minSizeForContent].height;
    151165   
    152166   fieldGrowth = newHeight - oldHeight;   
Note: See TracChangeset for help on using the changeset viewer.