• 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: NSButton with a delayed popup-menu?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSButton with a delayed popup-menu?


  • Subject: Re: NSButton with a delayed popup-menu?
  • From: Dix Lorenz <email@hidden>
  • Date: Fri, 11 Nov 2005 16:46:27 +0100

On 08.11.2005, at 16:01, Stephane Sudre wrote:

On 8 nov. 05, at 14:04, Dix Lorenz wrote:

how would I go about creating an NSButton like the Build-button (and others) in XCode? If the user just clicks it, it acts like a regular button, if he clicks and holds a menu pops up? Safari uses the same for it's back/forward button...


This would require using the mouseDown: mouseUp and mouseDragged:. Something like this:

1. mouseDown:

. render the button highlighted
. delay the apparition of the popup menu with:

- (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay;

2. mouseDragged:

. If the mouse cursor is outside the button frame and was previously inside

=> cancel the Perform request
=> render the button normal state

. If the mouse cursor is inside the button frame and was previously inside

=> render the button highlighted
=> delay the apparition of the popup menu

3. mouseUp:

. cancel the Perform request

. launch the standard action.

The delayed method would popup the menu.

... and render the button unhighlighted.

Now what would be interesting to see is whether the mouseUp: method of the button class is going to be called when you select an item from the menu.

It's not, that's why the menu-popup also needs to unhighlight the button.


My $0.02

Thanks a lot for those, that was exactly what I was looking for.

Dix

_______________________________________________
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


References: 
 >NSButton with a delayed popup-menu? (From: Dix Lorenz <email@hidden>)
 >Re: NSButton with a delayed popup-menu? (From: Stephane Sudre <email@hidden>)

  • Prev by Date: Closing a sheet
  • Next by Date: Re: Closing a sheet
  • Previous by thread: Re: NSButton with a delayed popup-menu?
  • Next by thread: Re: NSButton with a delayed popup-menu?
  • Index(es):
    • Date
    • Thread