Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

CPTextField's becomeFirstResponder

#29

There's a slight problem with CPTextField's becomeFirstResponder. For example, in the attached code, when the page first loads and you type something and press enter, there's no data in the Javascript alert. When you click on the text field with your mouse, the field mysteriously deletes the text and then what ever you type in appears in the Javascript alert.

Also, when setEditable is not explicitly set to YES and you use becomeFirstResponder, the field becomes semi-editable in the sense that you can edit the text field but you can't submit the data.

Reported by ronin-31544 (at lighthouseapp) · September 9th, 2008 @ 11:24 AM

State: invalid
Milestone: 0.5.2
Assigned to: nobody

Activity

  1. Ross Boucher
    Ross Boucher
    • Milestone set to 0.5.2
    • Tag changed from appkit, bug to appkit, bug

    September 17th, 2008 @ 07:53 PM

  2. Ross Boucher
    Ross Boucher
    • State changed from new to invalid

    Alright, the problem here is that you're not supposed to manually call becomeFirstResponder. In order to make a view the first responder, you're supposed to do something like

    [myWindow makeFirstResponder:someView];

    So, becomeFirstResponder wasn't expecting to be called directly. The reason it doesn't work is that it shouldn't be allowed to be first responder if it isn't editable, and you hadn't made it editable yet.

    So, if you make it editable, add it to the window, and after that call:

    
    	[[textField window] makeFirstResponder:textField];
    

    Then, it should work as expected.

    September 29th, 2008 @ 10:22 AM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.