Re: Mouse click vs. mouse held down
Re: Mouse click vs. mouse held down
- Subject: Re: Mouse click vs. mouse held down
- From: cricket <email@hidden>
- Date: Mon, 7 Jun 2004 09:02:51 -0700
An easy way to do this (IMHO) is to create an NSTimer in mouseDown:
that fires after the 'hold' interval. In mouseUp: you can invalidate
and release the timer. In the method that the timer calls, pop up the
menu.
- cricket
On Jun 7, 2004, at 8:17 AM, Ken Tabb wrote:
Hi folks,
how does one discriminate between a single click (i.e. click mouse
down, then let it go) and a click-and-hold (i.e. click mouse down and
keep it there, kind of like a mouse drag but without necessarily
moving it around the screen)? I'm only needing left button
functionality but cannot see a way of telling when the mouse is being
held down vs. when it is clicked and released.
In case you're wondering, I want to make a button kind of like Xcode's
toolbar buttons, where clicking on them (and letting go) does
something, whereas clicking on them and holding brings up a popup menu
for the button. Making the menu etc. is fine, but discriminating
between types of mouse click is driving me crazy.
NSEvent's clickCount: method returns 1 whether the mouse is still
being held down or not. Unless I double click it of course in which
case clickCount: returns 2 on the 2nd click (but 1 between clicks).
mouseDown: works as expected, but it doesn't tell me whether the mouse
is _still_ down or not. And mouseDragged: only works if the mouse
moves while down (which is not guaranteed to be the case, as the user
won't be dragging stuff from/to it).
I'm guessing I could perform some housekeeping in terms of "did the
mouse go down, if so has there been a mouseUp event since?" etc. but
this seems terribly inefficient (you haven't seen the way I code) and
must be a semi-regular thing that people want to do? So I'm hoping it
doesn't have to come to this.
I know I could use control click, but that seems ugly for those of us
with one button mice. Or of course I could put "2 button mouse" as one
of the system requirements!
If I'm barking up the wrong tree, please feel free to mock me in this
public forum, but please also include the 'obvious' way of doing it
8^)
Thanks in advance for any light you can shed,
Ken
- - - - - - - - - -
Dr. Ken Tabb
Mac & UNIX Technical bloke (C, C++, Obj-C, Java) - Health & Human
Sciences
Machine Vision & Neural Network researcher bloke - Computer Science
Dept
University of Hertfordshire, UK
http://www.health.herts.ac.uk/ken/
Certified non-Microsoft Solution Provider
_______________________________________________
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.
---------->
We salute the lone knife maker of today. He or she is a living
repository for a knowledge and tradition that spans millennia.
_______________________________________________
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.