• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: selectText of NSTextField on focus
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: selectText of NSTextField on focus


  • Subject: Re: selectText of NSTextField on focus
  • From: "Gary L. Wade" <email@hidden>
  • Date: Mon, 06 Jul 2015 11:12:46 -0700

You want to select the text using the associated text view of the NSTextField control.
--
Gary L. Wade (Sent from my iPhone)
http://www.garywade.com/

> On Jul 6, 2015, at 10:54 AM, Richard Charles <email@hidden> wrote:
>
>
>> On Jul 6, 2015, at 10:15 AM, Richard Charles <email@hidden> wrote:
>>
>> I have a NSTextField subclass that selects all of the text when the user clicks it. This is accomplished by overriding becomeFirstResponder.
>>
>> - (BOOL)becomeFirstResponder
>> {
>>   BOOL result = [super becomeFirstResponder];
>>   if(result) {
>>       [self performSelector:@selector(selectText:) withObject:self afterDelay:0];
>>   }
>>   return result;
>> }
>>
>> http://stackoverflow.com/questions/2195704/selecttext-of-nstextfield-on-focus
>>
>> This has worked perfectly for years until 10.10 Yosemite. Now when the user clicks into the text field nothing is selected.
>>
>> Also the following error will often occur on 10.10 Yosemite when clicking on the text field.
>>
>> 2015-07-06 10:09:04.287 MyApp[727:15035] Bad cursor rect event, flags = 256
>>
>> Does anyone have any insight into what is going on?
>>
>> Thanks so much.
>>
>> --Richard Charles
>
> Update
>
> The documentation for -[NSTextField selectText:] states "If the receiver isn’t in some window’s view hierarchy, this method has no effect.”
>
> I have verified that the text field is in the window’s view hierarchy. I have verified that -[NSTextField selectText:] is getting called. (Actually it is getting called twice, once by the frameworks for some reason, and once by me.) Calling the method -[NSTextField isSelectable] returns YES.
>
> It appears that -[NSTextField selectText:] is broken in 10.10 Yosemite. It just does not work.
>
> --Richard Charles

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >selectText of NSTextField on focus (From: Richard Charles <email@hidden>)
 >Re: selectText of NSTextField on focus (From: Richard Charles <email@hidden>)

  • Prev by Date: Re: selectText of NSTextField on focus
  • Next by Date: Errors resulting from Cocoa datatype changes 10.9 -> 10.10
  • Previous by thread: Re: selectText of NSTextField on focus
  • Next by thread: Re: selectText of NSTextField on focus
  • Index(es):
    • Date
    • Thread