Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 25, 2009, 04:39 AM   #1
xiaohuli170
macrumors newbie
 
Join Date: Jan 2009
Which delegate method I should use when I clicked a textfield?

When I clicked on the textfield,I want to open a panel. I think that I should use a delegate method to respond the clicked event. I found that the method - (void)textDidBeginEditingNSNotification *)aNotification not work , and then the method - (void)controlTextDidBeginEditingNSNotification *)aNotification worked ,but I found this method worked when I edited the textfield not to cliked it ,why? and that when I edited the textfield again ,This method not to work ,why?
xiaohuli170 is offline   0 Reply With Quote
Old Mar 25, 2009, 12:54 PM   #2
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
NSTextFields don't by default handle clicking - that's what buttons are for

If you want this behavior, subclass it and override mouseDown.
kainjow is offline   0 Reply With Quote
Old Mar 25, 2009, 09:53 PM   #3
xiaohuli170
Thread Starter
macrumors newbie
 
Join Date: Jan 2009
Sorry , I don't know what your means is . can you explain your answer in details.Thanks a lot.
xiaohuli170 is offline   0 Reply With Quote
Old Mar 26, 2009, 12:00 AM   #4
GorillaPaws
macrumors 6502a
 
GorillaPaws's Avatar
 
Join Date: Oct 2003
Location: Richmond, VA
Quote:
Originally Posted by xiaohuli170 View Post
Sorry , I don't know what your means is . can you explain your answer in details.Thanks a lot.
What he's saying is that the behavior you're looking for (opening a panel when clicking on a NSTextField) isn't something NSTextFields are really designed to do. The typical pattern is to use an NSButton to bring up a panel. If you really need this behavior to work in this manner then you can subclass the NSTextField and override the mouseDown method in your own custom class to bring up your panel instead of what the normal behavior of that method is (selecting the field--I'm assuming).

Edit: Typically, it's a bad idea to alter the default behaviors of standard UI elements. Users expect things to happen in a certain way when they interact with the GUI. Violating those expectations can lead to confusion and possibly even concern that your app is broken/bugged. In other words, you might want to re-think your design decisions a bit to see if this is the best implementation.

Last edited by GorillaPaws; Mar 26, 2009 at 12:13 AM.
GorillaPaws is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
textfield value not getting saved to nsuserdefaults abcdefg12345 Mac Programming 5 May 8, 2014 06:43 PM
Limit UIAlertView TextField delegate. IDMah iPhone/iPad Programming 7 Nov 6, 2013 08:30 PM
Limit textfield character length abcdefg12345 Mac Programming 5 Oct 25, 2013 11:13 AM
Class Method -> Function -> Instance Method? Blakeasd Mac Programming 11 Jun 19, 2013 02:53 AM
Automatic calculate when textField changes sa22 iPhone/iPad Programming 1 Jun 22, 2012 07:37 PM

Forum Jump

All times are GMT -5. The time now is 07:38 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps