I am having trouble allowing a user to drag an item, whilst also allowing
them to click the item. I am using mousedown, mousemove and mouseup. It
works if I click the button carefully, but if there is any mouse movement,
then it is interpreted as a drag, and the click does not work. What I want
is a way to only do the drag if the mouse movement is above a threshold. Is
this possible?
Here is the basic code:
private void ItemToolStripBu tton_MouseDown( object sender, MouseEventArgs e)
{
ToolStripButton btn = ((ToolStripButt on)sender);
if (e.Button == MouseButtons.Ri ght)
{
//show contextmenu
}
else
{
bMouseDown = true;
}
}
private void ItemToolStripBu tton_MouseMove( object sender, MouseEventArgs e)
{
if ((bMouseDown) && (e.Button == MouseButtons.Le ft))
{
ToolStripButton btn = ((ToolStripButt on)sender);
btn.DoDragDrop( btn.Tag, DragDropEffects .Copy);
}
}
}
private void ItemToolStripBu tton_MouseUp(ob ject sender, MouseEventArgs e)
{
ToolStripButton btn = ((ToolStripButt on)sender);
if (e.Button != MouseButtons.Ri ght)
{
//perform the onclick code here
bMouseDown = false;
}
Much Thanks
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
them to click the item. I am using mousedown, mousemove and mouseup. It
works if I click the button carefully, but if there is any mouse movement,
then it is interpreted as a drag, and the click does not work. What I want
is a way to only do the drag if the mouse movement is above a threshold. Is
this possible?
Here is the basic code:
private void ItemToolStripBu tton_MouseDown( object sender, MouseEventArgs e)
{
ToolStripButton btn = ((ToolStripButt on)sender);
if (e.Button == MouseButtons.Ri ght)
{
//show contextmenu
}
else
{
bMouseDown = true;
}
}
private void ItemToolStripBu tton_MouseMove( object sender, MouseEventArgs e)
{
if ((bMouseDown) && (e.Button == MouseButtons.Le ft))
{
ToolStripButton btn = ((ToolStripButt on)sender);
btn.DoDragDrop( btn.Tag, DragDropEffects .Copy);
}
}
}
private void ItemToolStripBu tton_MouseUp(ob ject sender, MouseEventArgs e)
{
ToolStripButton btn = ((ToolStripButt on)sender);
if (e.Button != MouseButtons.Ri ght)
{
//perform the onclick code here
bMouseDown = false;
}
Much Thanks
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Comment