How to make key shortcuts and mouse click trigger controlTextDidEndEditing:
How to make key shortcuts and mouse click trigger controlTextDidEndEditing:
- Subject: How to make key shortcuts and mouse click trigger controlTextDidEndEditing:
- From: James Housley <email@hidden>
- Date: Sat, 5 Mar 2005 12:57:52 -0500
I am still new at this, but I think I have most of this figured out.
My program is a front end to creating a file. I have a mix of
NSTextField, NSTextViews and some assorted buttons. Currently the
program is NSDocument based, and so far that seems right but I haven't
full decided. I have a backing structure that contains the real
contents because the there is a table view that lists the entry for
editing.
When editing one of the NSTextViews and pressing Apple-S or File->Save
the file is correctly saved and documentIsEdited is cleared just fine.
When editing one of the NSTextFields I have captured
controlTextDidBeginEditing: and controlTextDidEndEditing: and store the
values fine and feed into the undo manager without a problem when you
leave the field be clicking on one of the buttons or other fields.
To make this simple, if the only editing that is done is in a
NSTextField and File->Save or Apple-S is pressed
controlTextDidEndEditing: is not triggered.
Since I do get controlTextDidBeginEditing: I tried forcing
controlTextDidEndEditing: with a notification and that works, except
after the file is saved, which calls [self
updateChangeCount:NSChangeCleared], the change is still active and the
document is still shown as being saved.
How do I solve this. I am really have to avoid an "Apply" button. Do
I...
1) Subclass NSTextField and override keyDown:/keyUp: to look for the
short cut command and trigger the controlTextDidEndEditing there? But
what about the toolbar and menu options?
2) Create custom NSTextViews that are a single line without scroll
bars? But I would still want to capture keys so that
Return/Tab/Shitf-Tab would work and send the user to the next field.
That doesn't sound nice.
3) Is there a better control to use?
4) Something I haven't even thought of.
Thanks,
Jim
--
/"\ ASCII Ribbon Campaign .
\ / - NO HTML/RTF in e-mail .
X - NO Word docs in e-mail .
/ \ -----------------------------------------------------------------
email@hidden http://www.FreeBSD.org The Power to Serve
email@hidden http://www.TheHousleys.net
---------------------------------------------------------------------
Do not meddle in the affairs of dragons, for you are crunchy and taste
good with ketchup.
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden