tap-and-hold over a list

D

Dean Grimm

Hi,
I'm sure I'm missing something totally obvious, but I
can't quite figure out how to get tap-and-hold
coordinates. I have added a context menu to a list box,
and need to know where the tap-and-hold occurred so I can
then do a hit test to figure out which list item the tap
occurred over. My problem is that it doesn't appear that
mousedown events are fired if it's a tap-and-hold. And the
ContextMenu.Popup event doesn't give you coordinates like
the mosedown event does. Any ideas how to detect where the
tap-and-hold occurred?

Thanks a bunch,
Dean
 
G

Ginny Caughey [MVP]

Dean,

Wouldn't the SelectedItem of the listbox give you the information you need?
(The CE 4.1 device I work with doesn't support tap-and-hold so I can't test
it at the moment.)
 
D

Dean

Hi Ginny,
No, unfortunately if it's a tap-and-hold operation, none
of the normal mouse event chain occurs, and therefore the
list item doesn't get selected. Sure would be nice if the
Popup event handler gave you the mouse coords, but alas,
it does not.
Dean
 
A

Alex Feinman [MVP]

Popup event handler does not prevent you from getting mouse coords via
Control.MousePosition. Or, if you prefer, you can P/Invoke
[DllImport("coredll")]
extern static bool GetCursorPos(out Point pt);

The point will be in screen coordinates so you will need to use
ListBox.PointToClient() to convert it to the listbox client coordinates
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top