• 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: NSTextField will not become editable in a borderless window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextField will not become editable in a borderless window


  • Subject: Re: NSTextField will not become editable in a borderless window
  • From: Graham Cox <email@hidden>
  • Date: Thu, 22 May 2008 22:52:31 +1000

Me again ;-)

It just occurred to me - have you tried the following overrides in NSWindow?:

- (BOOL) canBecomeKeyWindow { return YES; }
- (BOOL) acceptsFirstResponder { return YES; }
- (BOOL) becomeFirstResponder { return YES; }
- (BOOL) resignFirstResponder { return YES; }
Borderless windows are set up to return NO in these cases by default, so these overrides are necessary to force it back into the land of the living. If the text field now works, but shows the inactive appearance, THEN try the active hack.


G.




On 22 May 2008, at 10:47 pm, Graham Cox wrote:

Found it just after I posted:

- (BOOL) _hasActiveControls
{
	return YES;
}


Also, while this works to show an active *appearance* for buttons, pop-ups and so on, I've never tried it with text fields. It's a quick thing to try though. It would be useful for Apple to provide a properly supported way to do this, to allow "pop-up controls" though perhaps the new view-in-a-menu-item mechanism will do that now.



hth,

G.


On 22 May 2008, at 10:40 pm, Graham Cox wrote:

Peter, I've run into something similar and I think it has to do with the window server not making a window active (i.e. main and key) if it has the borderless attribute. The workaround I ended up using was to override a private undocumented NSWindow method which controls use to query the active state of the window, to always return YES.

Unfortunately I've dug through a mountain of code but can't find where I used it. Someone else may remember this trick and help me out... of course, it's not a great solution but it works from 10.3 through 10.5 so far...

G.






On 22 May 2008, at 10:13 pm, Peter Burtis wrote:

When I add an NSTextField to a borderless window, nothing I do will make it editable. Specifically, running the code below, the text field just won't work. (I've tried it with all backing types, BTW.)

NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(300,300,300,300) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
NSTextField *field = [[NSTextField alloc] init];
[field setEditable:YES];
[window setContentView:field];
[window makeKeyAndOrderFront:self];


But change the styleMask to NSTitledWindowMask and it works as expected.

What am I missing? Is it impossible to do this for some reason? On the subject of NSBorderlessWindowMask, the docs give the rather opaque guidance, "Useful only for display or caching purposes," as if a window was useful for anything other than display. Is there some other, better way to create a completely custom window?

I'm running 10.5.2, if that matters.

Thanks,
Peter Burtis
_______________________________________________

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

_______________________________________________

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

_______________________________________________

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

_______________________________________________

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


  • Follow-Ups:
    • Re: NSTextField will not become editable in a borderless window
      • From: Peter Burtis <email@hidden>
References: 
 >NSTextField will not become editable in a borderless window (From: Peter Burtis <email@hidden>)
 >Re: NSTextField will not become editable in a borderless window (From: Graham Cox <email@hidden>)
 >Re: NSTextField will not become editable in a borderless window (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: NSTextField will not become editable in a borderless window
  • Next by Date: Displaying NSAttributedStrings in an NSTableView with non-uniform row height
  • Previous by thread: Re: NSTextField will not become editable in a borderless window
  • Next by thread: Re: NSTextField will not become editable in a borderless window
  • Index(es):
    • Date
    • Thread