• 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: Pressable Button
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pressable Button


  • Subject: Re: Pressable Button
  • From: Stéphane Sudre <email@hidden>
  • Date: Tue, 16 Dec 2008 18:56:54 +0100


On Dec 16, 2008, at 4:02 PM, Gerriet M. Denkmann wrote:

I am trying to build a pressable button: an on-off button (subclass of NSButton), which, if pressed for more than 0.3 seconds, displays a context menu.

My idea was:
Start a non-repeating timer in mouseDown: and schedule it with NSEventTrackingRunLoopMode.


In mouseUp: invalidate the timer.

And in timerFired: display the context menu.

But: mouseUp: is never called. So: where should I invalidate the timer?

And: if I send: [ NSMenu popUpContextMenu: menu withEvent: mouseDownEvent forView: self ]
the button gets all messed up: no more drawRect: on mouse up, no action sent.


Obviously I am doing it all wrong.

I have a button like this.

I use performSelector:withObject:afterDelay: in the mouseDown:, cancel the delayed perform in mouseDragged: if the mouse cursor is outside the button frame, put back the delayed perform if the mouse cursor comes back in the button frame.

On mouseUp: I cancel the delayed perform if needed.


_______________________________________________

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: Pressable Button
      • From: "Gerriet M. Denkmann" <email@hidden>
    • Re: Pressable Button
      • From: "Gerriet M. Denkmann" <email@hidden>
References: 
 >Pressable Button (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Re: More - Safari Download Security Alerts
  • Next by Date: Re: Sublclassing NSThread
  • Previous by thread: Pressable Button
  • Next by thread: Re: Pressable Button
  • Index(es):
    • Date
    • Thread