[28248] users/rhwood/Pallet/IFVerticallyExpandingTextField.m
source_changes at macosforge.org
source_changes at macosforge.org
Sun Aug 26 02:19:45 PDT 2007
Revision: 28248
http://trac.macosforge.org/projects/macports/changeset/28248
Author: rhwood at macports.org
Date: 2007-08-26 02:19:44 -0700 (Sun, 26 Aug 2007)
Log Message:
-----------
Use minSizeForContent method to determine size instead of mucking with selection.
Modified Paths:
--------------
users/rhwood/Pallet/IFVerticallyExpandingTextField.m
Modified: users/rhwood/Pallet/IFVerticallyExpandingTextField.m
===================================================================
--- users/rhwood/Pallet/IFVerticallyExpandingTextField.m 2007-08-26 07:37:05 UTC (rev 28247)
+++ users/rhwood/Pallet/IFVerticallyExpandingTextField.m 2007-08-26 09:19:44 UTC (rev 28248)
@@ -66,6 +66,7 @@
- (void) alterAutoresizeMasksForViews: (NSArray *)sibViews
surroundingView: (NSView *)originView;
- (void) restoreAutoresizeMasks;
+- (NSSize)minSizeForContent;
@end
@@ -121,7 +122,7 @@
[myWindow makeFirstResponder: self];
// Set cursor to end, breaking the selection
- [fieldEditor setSelectedRange: NSMakeRange([[self stringValue] length], 0)];
+ //[fieldEditor setSelectedRange: NSMakeRange([[self stringValue] length], 0)];
}
[self autosizeHeight: fieldEditor];
@@ -136,6 +137,20 @@
/* Private methods */
+- (NSSize)minSizeForContent {
+ NSRect frame = [self frame];
+ NSRect newf = frame;
+ NSTextView* editor = nil;
+ if ((editor = (NSTextView*)[self currentEditor])) {
+ newf = [[editor layoutManager] usedRectForTextContainer:[editor textContainer]];
+ newf.size.height += frame.size.height-[[self cell] drawingRectForBounds:frame].size.height;
+ } else {
+ newf.size.height = HUGE_VALF;
+ newf.size = [[self cell] cellSizeForBounds:newf];
+ }
+ frame.size.height = newf.size.height;
+ return frame.size;
+}
- (void) autosizeHeight: (NSTextView *)fieldEditor {
NSRect newFrame = [self frame];
@@ -146,8 +161,7 @@
if (isCollapsed)
newHeight = 0;
else
- newHeight = [[fieldEditor layoutManager] usedRectForTextContainer:
- [fieldEditor textContainer]].size.height + IFVerticalPadding;
+ newHeight = [self minSizeForContent].height;
fieldGrowth = newHeight - oldHeight;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070826/b70b8620/attachment.html
More information about the macports-changes
mailing list