|
From: | David Ayers |
Subject: | Re: NSTextField questions |
Date: | Mon, 16 Sep 2002 21:13:50 +0200 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826 |
Dirk Lattermann wrote:
Sorry for answering so late, but I hardly had time to actually do some debugging here. Thus far it seems that the BEGAN_EDITING macro in NSTextView's shouldChangeTextInRange:replacementString: doesn't return YES when the actual editing begins. This is the method that is supposed to post the notifcation. I'll try to continue to find out what's going on.The delegate of the NSTextField doesn't get a controlTextDidBeginEditing: message. It works with controlTextDidChange: and ...EndEditing. In fact, I think NSTextField itself doesn't receive textDidBeginEditing, which I found out when subclassing NSTextField.
Well not really, the is no notification sent when an object becomes firstResponder. The NSControlTextDidBeginEditingNotification should be sent once a key is pressed. (But as noticed this isn't working.) In fact it's not that easy to trace this currently. NSTextFields mechanism for becoming firstResponder is not working correctly at the moment, but I believe Nicola is working on a solution there.The question is: how can I figure out when an NSTextField has just become the firstResponder? Is there a notification that is sent in this case? (this might be related to the bug above because I don't know if textDidBeginEditing is supposed to be used for this or if it is sent after the first editing key press in a text field).
But even once he has fixed it, it is not necessarily trivial. When you tell an NSWindow to make an NSTextField firstResponder through the makeFirstResponder method, it ultamtliy should do this by invoking NSTextField's becomeFirstResponder. It is the responsiblity of the NSTextField, to propagate the firstResponder to the window's fieldEditor, which is an NSTextView shared by all NSTextFields of the window. Everytime another NSTextField's becomeFirstResponder is invoked, it takes this shared NSTextView and sets it up for it's needs, makes it firstResponder therefor the NSTextField resignsFirstResponder, before the original becomeFirstResponder will return.
I just went through describing this to show that in an event cycle the firstResponder status is very volatile. It would make more sens to ask the Window for it's current firstResponder in some defined state (for example when processing an action method.)
Maybe you could detail a bit more of what you want to do. And I'll look into the notification bug.
Cheers, Dave
[Prev in Thread] | Current Thread | [Next in Thread] |