Re: NSOutlineView editing & selection issues
Re: NSOutlineView editing & selection issues
- Subject: Re: NSOutlineView editing & selection issues
- From: "l.m.orchard" <email@hidden>
- Date: Fri, 24 Aug 2001 01:43:56 -0400
On Thursday, August 23, 2001, at 04:05 PM, tyler wrote:
>
>
> So, is there anyway to start editing a column with the insertion point
>
> at the *end* of the column, without selecting all?
>
>
I might try to hack around this by creating the item with no characters
>
and then putting it into editing mode (which you seem to be able to do),
>
(and only if necessary selecting all of it) and then paste in the
>
characters you are currently initializing it with. This gets in your
>
current characters and the cursor should be at the end. I haven't tried
>
this in the outline view, but I've done this sort of thing elsewhere.
I'm still working on this one, but I think I'm getting close..
>
Hmm. This sounds like you need to change the behavior of the underlying
>
NSCell object (which is probably a NSTextFieldCell) in the outline view.
>
But I'm guessing. Also look at the fieldEditor stuff in NSWindow as
>
it explains a lot about what's going on during editing and can perhaps
>
allow you to do one of several things that will make the field editor end
>
editing; makeFirstResponder on something other than the field editor, or
>
at a worst case, endEditingFor: -- See NSWIndow docs for more details).
>
>
I'd like to hear about what ends up working :-)
Well, after doing a lot of scary hackish stuff, I finally seem to have
figured it out. I really went in a roundabout way, and (this will
probably get some chuckles from people) even ended up looking at
NSTableView.m in GNUStep just to see if there was a hint. There was. It
led me back to the NSText docs, which listed some constants that "specify
the movement between fields" but unfortunately, "Description forthcoming,"
was all that was waiting for me there.
But it did say that these were used in NSTextDidEndEditingNotification,
which is handled in the delegate (NSOutlineView) as textDidEndEditing:,
with the desired constant in the notification userInfo, key
"NSTextMovement". So to disable movement between fields, made a poseAs
class for NSOutlineView, filtered out the userInfo for a blank dictionary
(since the NSTextMovement was the only dict entry), and passed that
notification onto the real NSOutlineView.
@implementation DSXOutlineView
+ (void)load {
[DSXOutlineView poseAsClass:[NSOutlineView class]];
}
- (void)textDidEndEditing:(NSNotification *)notification {
return [super textDidEndEditing:[NSNotification
notificationWithName:[notification name] object:[notification object]
userInfo:[NSDictionary dictionary]]];
}
@end
So, when editing and return is hit, editing completes, and does not move
onto the next item and the edited item remains selected. There is a
little bit of funkiness going on (ie. cursor keys navigate outline before
edit, they do not after edit until a mouse click on the outline again.
first responder stuff?), but this seems to work.
--
Leslie Michael Orchard <email@hidden>
ICQ: 492905 (home) 11082089 (work)
"...see you space cowboy..."