#29 ✓invalid
ronin-31544 (at lighthouseapp)

CPTextField's becomeFirstResponder

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

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.

Comments and changes to this ticket

  • Ross Boucher

    Ross Boucher September 17th, 2008 @ 07:53 PM

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

    Ross Boucher September 29th, 2008 @ 10:22 AM

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

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Cappuccino Web Framework, including AppKit, Foundation, and Objective-J.

Shared Ticket Bins

People watching this ticket

Attachments

Tags

Pages