Professional Web Applications Themes

becomeFirstResponder and key equiv. for OK button - Mac Programming

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....

  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. #2

    Default Re: becomeFirstResponder and key equiv. for OK button

    In article <abz-0908031757460001192.168.1.3>, Alain Birtz
    <abzvideotron.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 doentation
    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]cmhbDistributed.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]cmhmac.com[/email]
    Chris Hanson Guest

Similar Threads

  1. does ActionScript have java equiv of.....
    By freeeeeman in forum Macromedia Flex General Discussion
    Replies: 3
    Last Post: February 17th, 03:41 PM
  2. javascript=escape() perl=(looking for equiv)
    By john in forum PERL Miscellaneous
    Replies: 4
    Last Post: September 16th, 06:54 AM
  3. Perl equiv to PHP file() ?
    By Amittai Aviram in forum PERL Miscellaneous
    Replies: 4
    Last Post: August 18th, 06:48 PM
  4. Perl equiv to PHP file()
    By Amittai Aviram in forum PHP Development
    Replies: 0
    Last Post: August 18th, 05:49 PM
  5. Network problem mac equiv windoze command
    By Wookiee in forum Mac Applications & Software
    Replies: 3
    Last Post: July 19th, 06:13 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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