• 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
NSTextField manipulation -- editing, greying out etc.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTextField manipulation -- editing, greying out etc.


  • Subject: NSTextField manipulation -- editing, greying out etc.
  • From: Ben Dougall <email@hidden>
  • Date: Sat, 18 Jun 2005 23:58:45 +0100

hello,

i want to have a text field that appears more fixed than usual, but in fact is just as editable. greyed out when not being edited. is editable (becomes highlighted) on one single click. then goes back to greyed out, no selection nor focus ring when editing finished.

i've subclassed NSTextField in order to do implementations of mouseDown: and textDidEndEditing:.

both awakeFromNib and textDidEndEditing just contain [self fix]; and the mouseDown method just contains [self edit];.

- (void)fix
{
[self setTextColor:[NSColor colorWithCalibratedRed:0.5 green:0.5 blue:0.5 alpha:1.0]];
[self setSelectable:NO];
}


- (void)edit
{
    [self setTextColor:[NSColor blackColor]];
    [self setSelectable:YES];
    [self setEditable:YES];
    [self selectText:self];
}

also in IB i've inserted a value into the text field.

when the window first appears, the text field is as i want -- no focus, not selected and grey text. a single mouse down on the field also gives what i want -- immediately text becomes black and is selected, and the field gets the focus ring. but from then on it doesn't do what i'm after. when i press enter -fix is called but the effect is the text does go grey but it remains highlighted (but now in a grey selection colour). also the text field keeps the blue focus ring. then if i click on the text field again -edit isn't even called this time, so the mouseDown method isn't being called anymore for some reason.

so how can i deselect the text and get rid of the focus ring, in -fix? and why isn't mouseDown being called anymore after the first time? -- it almost seems that something extra on top of the text field is covering and stopping the clicks getting through because the pointer changes to an i-beam when over the text field which doesn't happen right at the start, and it's right at the start that mouseDown works for the text field. also mouseDown does get called if the frame of the text field is clicked. :/ pretty annoying.

extra question: how can i have -fix called when the user, when finished editing, clicks anywhere in the window outside the text field (rather than pressing tab or enter to end editing)?

base os x version: 10.2.8.

thanks, ben.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSTextField manipulation -- editing, greying out etc.
      • From: Ben Dougall <email@hidden>
  • Prev by Date: Problem with multiple NSTableViews
  • Next by Date: Per-User login process
  • Previous by thread: Re: Problem with multiple NSTableViews
  • Next by thread: Re: NSTextField manipulation -- editing, greying out etc.
  • Index(es):
    • Date
    • Thread