becomeFirstResponder and key equiv. for OK button

Ask a Question related to Mac Programming, Design and Development.

  1. #1

    Default becomeFirstResponder and key equiv. for OK button

    The action for the OK button check if the editable NSTextField
    hold valid date. For error the faulty NSTextField is set to
    first responder with becomeFirstResponder.

    This work fine when the OK button is clicked but when the Return key
    (key equiv. for the OK button) is hit becomeFirstResponder does nothing:
    the text cursor stay in the (wrong) NSTextField.

    The OK action method is called but becomeFirstResponder does nothing.

    (NSTextField and button in NSPanel)

    What can I do ?

    Thank you.
    Alain Birtz Guest

  2. Similar Questions and Discussions

    1. does ActionScript have java equiv of.....
      does ActionScript have java equiv of: Class cls = Class.forName("SomeClass"); i don't want an instance of the object, just an instance of the...
    2. javascript=escape() perl=(looking for equiv)
      anybody know what the per equilivent to the javascript escape() function. thanks in advance john
    3. Perl equiv to PHP file() ?
      Does Perl have an equivalent to the PHP function file()? file() reads a file into an array. More importantly for me, you can pass a URL to file(),...
    4. Perl equiv to PHP file()
      (Slightly OT.) Does anybody here who works in both PHP and Perl happen to know whether there is a Perl equivalent to PHP's file(url)? I need to...
    5. Network problem mac equiv windoze command
      I've been having problems with my local network and was supplied with the following windoze solution. I have all OS 9.1 machines. Is there a way...
  3. #2

    Default Re: becomeFirstResponder and key equiv. for OK button

    In article <abz-0908031757460001@192.168.1.3>, Alain Birtz
    <abz@videotron.ca> wrote:
    > The action for the OK button check if the editable NSTextField
    > hold valid date.
    You should try to do this with a formatter, if possible. If you just
    need to ensure that the date the user entered is properly formatted, an
    NSDateFormatter will do this for you automatically and even allow
    natural-language entry (like "today" and "Friday").

    If you need to do something more complicated like validate a date
    range, then what you're doing now is probably an acceptable solution.
    (It'd be better though not to let the user enter out-of-range dates to
    begin with, but that is more complex to code.)
    > For error the faulty NSTextField is set to
    > first responder with becomeFirstResponder.
    You should be using -[NSWindow makeFirstResponder:] instead, since the
    first responder is really a property of the window. The documentation
    for -[NSResponder becomeFirstResponder] says this quite explicitly.
    ("Never invoke this method directly.")

    -[NSWindow makeFirstResponder:] ensures that the current first
    responder is resigned, if possible, and that the responder is changed,
    if possible, and will return NO if for some reason it's not possible.

    -- Chris

    --
    Chris Hanson, bDistributed.com, Inc. | Email: [email]cmh@bDistributed.com[/email]
    Custom Application Development | Phone: +1-847-372-3955
    [url]http://bdistributed.com/[/url] | Fax: +1-847-589-3738
    [url]http://bdistributed.com/Articles/[/url] | Personal Email: [email]cmh@mac.com[/email]
    Chris Hanson Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139