• 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: current mouse buttons state
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: current mouse buttons state


  • Subject: Re: current mouse buttons state
  • From: Richard Fox <email@hidden>
  • Date: Thu, 13 Nov 2003 17:54:40 +1100

Anybody know how to determine the current mouse buttons state ? I need
to determine at some random interval wether the left mouse button is
down or up.
(I know [NSEvent mouseLocation] will give the current mouse location)

It is a deprecated function but
(BOOL) Button()
returns the state of the left (or, strangely enough, the middle) mouse
button.

It is a Carbon function so you must include the Carbon framework in
Frameworks.Linked Frameworks (where Cocoa.framework is).

NOOOOOOOOOO!!!

You don't want to do that. Unfortunately I don't know the correct API to use, but one thing that has stuck in my mind from a few WWDCs is a really simple demo of how not to poll for events. Basically, Button() is a very old API that predates multitasking, and it will hog the event loop like nothing else, stopping anything else from getting done.

Check the docs on Button() at

http://developer.apple.com/documentation/Carbon/Reference/ EventManagerLegacyRef/index.html

for alternatives.

Cheers,
Richard
--
Richard Fox
LiveTime Software
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: NSURL String formatting
  • Next by Date: Re: Quartz 2D drawing problems
  • Previous by thread: Re: current mouse buttons state
  • Next by thread: Terminate on Close
  • Index(es):
    • Date
    • Thread