• 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: Best practices for using standard window widgets in a custom window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best practices for using standard window widgets in a custom window


  • Subject: Re: Best practices for using standard window widgets in a custom window
  • From: Kevin Wojniak <email@hidden>
  • Date: Fri, 22 Jan 2010 09:03:57 -0800

I didn't pull my code from Chromium, I just noticed in my googling that they used the undocumented method that is required to get the mouse over effects to work.

I ended up sticking with the standard Cocoa buttons that NSWindow provides for my custom window as it requires the least amount of code to use. The main things I had to do are:

- Redraw the buttons when the window's key/main state changes
- Track the mouse to redraw the buttons when the mouse enters/exits the group of buttons
- Override in the button's superview _mouseInGroup: to return YES when the mouse is over any of the buttons
- After the window is minimized, make sure the buttons redraw again with the mouse not being over the buttons

I can post a sample project if someone wants, but I think that should cover it for anyone wanting to do this themselves.

Kevin


On Jan 20, 2010, at 8:56 PM, Jens Alfke wrote:

>
> On Jan 20, 2010, at 9:43 AM, Kevin Wojniak wrote:
>
>> NSWindow's standardWindowButton:forStyleMask: method works great for creating these buttons and adding to my custom (frame) view. However, the mouse over effect does not work without using undocumented methods. Mainly, overriding _mouseInGroup: in the button's superview (frame view) and returning YES when the mouse is over the buttons. This works, and I notice Google Chrome uses the same method, but I really dislike using undocumented APIs like this, especially for UI work.
>
> Funny you should point this out. I just found out the hard way that the code currently used in Chromium has some issues — it crashes on 'textured' windows for some reason. (Not currently a problem as Chromium has no textured windows, but I tried adding one the other day, and blammo.) So I wouldn't recommend anyone copy-and-paste it into their own project. Unfortunately it was the best solution the Chromium developers could come up with at the time … if anyone knows a better approach, we'd love to know.
>
> (In Chromium's case, the window does use the standard frame, but moves the buttons down 3 pixels to better center them against the tabs.)
>
> —Jens

_______________________________________________

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: 
 >Best practices for using standard window widgets in a custom window (From: Kevin Wojniak <email@hidden>)
 >Re: Best practices for using standard window widgets in a custom window (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: UIImageView display as "multiply"?
  • Next by Date: Re: CALayer resizing puzzle
  • Previous by thread: Re: Best practices for using standard window widgets in a custom window
  • Next by thread: NSOutlineView + selectionIndexPaths binding
  • Index(es):
    • Date
    • Thread