Further to this, I have come up with appears to be a reasonable solution, but I would like to solicit feedback about the approach:

Rather than insert a NSTextField directly, I am now inserting a NSView subclass (call it BJJCoverView) as a subview of the content view of the window. This subclass then inserts the NSTextField into as a subview and postions it properly. Since there is no drawing implemented for BJJCoverView, it is not visible to the user, but since we get events for the view, we can detect when the user clicks outside the NSTextField. This seems to work well.

I needed to override - (void)viewWillStartLiveResize to detect when the user clicks on the resize widget of the window as that captures the click (the BJJCoverView does not see the mouse down).

One thing I still need to work out:

Is there any way to pass the "mouseDown" event to the view that would have gotten the click if my BJJCoverView was not over the view? Do I just need to find the view for the mouseDown event, and then send it a mouseDown message?

Thanks!

B.J. Buchalter
Metric Halo
http://www.mhlabs.com

On May 19, 2010, at 7:32 PM, B.J. Buchalter wrote:

Hey Folks,

I would like to implement something that I would describe as "popup" text entry. Effectively I have a view that displays some textual information. I would like to make it so that if the user clicks on the view it becomes a text entry box.

I have worked out how to insert a NSTextField into the view hierarchy and make it the first responder. That works well.

What I would like to do is make it so that if the user hits tab or enter, the "popup" text entry is removed and the text that was entered is commited. I think I understand how to do that.

I also need for the popup text entry to be removed when the user clicks outside of the NSTextField.

In my Carbon version of this, I made a modal window that I stuck the text edit field into, and I could detect if there was a click outside that window.

With Cocoa, Ideally, I would rather just let the event loop run normally, but I can't work out how to detect if the user has clicked outside of the NSTextField. Is there any way to do this easily, or do I need to run a local eventloop, or do I need to go back to the way I did it in Carbon and stick the entire text entry into its own window?

Any guidance (or pointers to the relevant docs would be greatly appreciated!!

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to