Tuesday, 15 July 2014

.net - Why doesn't doubleclick event fire after mouseDown event on same element fires? -



.net - Why doesn't doubleclick event fire after mouseDown event on same element fires? -

i have mousedown event , click event on control. mousedown event used starting dragdrop operation. command using dirlistbox.

private sub dir1_mousedown(byval sender system.object, byval e system.windows.forms.mouseeventargs) handles dir1.mousedown dim lab new label lab.text = dir1.dirlist(dir1.dirlistindex) lab.dodragdrop(lab, dragdropeffects.copy) end sub

but when click on command mousedown event fires, click event not fire. if comment out "lab.dodragdrop(lab, dragdropeffects.copy)" in mousedown event click event gets fire. can both mousedown , click event gets fire when click on control?

this design. mousedown event captures mouse, control.capture property. built-in mouseup event handler checks if mouse still captured , mouse hasn't moved far, fires click event. problem calling dodragdrop() cancel mouse capture. since mouse events used implement drag+drop operation. you'll never click nor doubleclick event.

controls both need respond clicks and drag+drop usability problem. fixable however, need ensure user has moved mouse plenty original mouse downwards location, then start drag. create code this:

private mousedownpos point private sub dir1_mousedown(byval sender system.object, byval e system.windows.forms.mouseeventargs) handles dir1.mousedown mousedownpos = e.location end sub private sub dir1_mousemove(byval sender system.object, byval e system.windows.forms.mouseeventargs) handles dir1.mousemove if e.button , mousebuttons.left = mousebuttons.left dim dx = e.x - mousedownpos.x dim dy = e.y - mousedownpos.y if math.abs(dx) >= systeminformation.doubleclicksize.width orelse _ math.abs(dy) >= systeminformation.doubleclicksize.height '' start drag here ''... end if end if end sub

.net vb.net

No comments:

Post a Comment