Re: Controlling field editor for an outline view
Re: Controlling field editor for an outline view
- Subject: Re: Controlling field editor for an outline view
- From: Ken Thomases <email@hidden>
- Date: Thu, 10 Jan 2008 19:15:15 -0600
Are you perhaps still over-thinking? Can you use NSFormatter and its
editingStringForObjectValue: method?
Logically, the object value would be $(BUILD_LOC) and the formatter
would perform the substitution and show the resulting string. When
editing, it would revert to the "real" value.
-Ken
On Jan 8, 2008, at 8:32 PM, John Stiles wrote:
I think I was over-thinking the problem. Since I'm starting the
edit programmatically, after I call -editColumn:etc:, I just need
to grab the field editor with [[myOutlineView window]
fieldEditor:YES forObject:myOutlineView], and then call
[fieldEditor setString:myNewString]. Voila, it's done.
If I had to support regular edits (initiated by slow-clicking in a
cell), I could probably put a -performSelector:afterDelay: in -
setUpFieldEditorAttributes: and provide a zero delay. This would
give the field editor a chance to get warmed up, and then I could
swoop in and replace its contents.
FWIW, it looks like Xcode is doing something hokey here. If you
watch closely, when you click on it to begin an edit, it actually
visibly changes the cell's contents, and then editing begins 1/10
of a second later. If you time your clicks just right, you can
confuse it and it will leave cells in the "wrong" state (showing $
(STUFF) instead of a real path). Whoops! :)
John Stiles wrote:
I thought I found a good workaround. -setUpFieldEditorAttributes:
is, in fact, called whenever editing begins. However, it doesn't
seem to work. I tried this:
-(NSText*) setUpFieldEditorAttributes:(NSText*)textObj {
[textObj setString:@"This is a test"];
return textObj;
}
My code was definitely being called. But the field editor didn't
change its contents! "This is a test" never appeared.
:(
How is Xcode managing this trick??
John Stiles wrote:
I'm trying to set up a custom field editor for an NSOutlineView.
When it displays, its contents are not necessarily the same as
the cell being displayed by the outline view. For instance,
consider the Xcode project settings dialog—it has a table that
displays stuff like:
Build Location /Volumes/MyDrive/MyFolder
But when you go to edit it, it changes to
Build Location $(BUILD_LOC)
I'm basically trying to do something similar to that. So how is
this done?
If it matters, I'm beginning the edit session programmatically
(in this case, in response to a menu selection). I suppose in
this case I might be able to get away with changing the cell's
string just before the edit begins, and change it back as soon as
the edit completes, but that's pretty hokey; I think it would be
a cleaner solution to just put the appropriate text in the field
editor and leave the cell's string alone. I just can't manage to
make it work though.
I've tried using the delegate method -
control:textShouldBeginEditing: but this was a total bust; it's
not called until the user begins typing.
I've also tried adding -
editWithFrame:inView:editor:delegate:event: to my NSCell subclass
but this did not seem to ever be called, strangely. (I did notice
that -selectWithFrame:inView:… etc. /is/ being called, but that
is probably because I am using "select:YES" in my call to -
editColumn:row:withEvent:select:.)
_______________________________________________
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:
40blizzard.com
This email sent to email@hidden
_______________________________________________
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:
40blizzard.com
This email sent to email@hidden
_______________________________________________
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
_______________________________________________
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