determinating if the mouse button is still down - again

B

Barkingmadscot

I am try to find out how to check if the mouse button is held down.

The e.click =2 works, it allows me to enter the double click double.


I what the single click to do some different and then a click and
hold
to allow the drag and drop


I have looked at the mouseUp events be can not get it to work, when i
click and release my code does not enter mouseUP event?


See above for MouseDown Event


any ideas


Thanks


Barry


Private Sub tvNone_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles tvNone.MouseDown


Select Case e.Button.ToString


Case "Left"
If e.Clicks = 2 Then Exit Sub '# Exits to Double
click
event
If tvNone.SelectedNode Is Nothing Then Exit Sub '#
Exits if nothing is selected


'# Enable Treeview that node can be dropped into
Me.tvNone.AllowDrop = True
Me.tvRFQ.AllowDrop = True
Me.tvEnquiry.AllowDrop = False
Me.tvEval.AllowDrop = False
Me.tvRPT.AllowDrop = False
Me.tvPO.AllowDrop = False
Me.tvRAS.AllowDrop = False
Me.tvITD.AllowDrop = False
Me.tvRAD.AllowDrop = False


'# Get Selected node and node index
Dim DraggedNode As String = tvNone.SelectedNode.Text
Dim DraggedNodeIndex As Integer =
tvNone.SelectedNode.Index


'# Send info to DragDrag events
tvNone.DoDragDrop(Chr(40) & DraggedNode & Chr(41) &
Chr(40) & 0 & Chr(41), DragDropEffects.Move)
'# Remove Selected Node
tvNone.Nodes.RemoveAt(DraggedNodeIndex)


Case "Middle"


Case "Right"


End Select


End Sub
 
K

kimiraikkonen

I am try to find out how to check if the mouse button is held down.

The e.click =2 works, it allows me to enter the double click double.

I what the single click to do some different and then a click and
hold
to allow the drag and drop

I have looked at the mouseUp events be can not get it to work, when i
click and release my code does not enter mouseUP event?

See above for MouseDown Event

any ideas

Thanks

Barry

Private Sub tvNone_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles tvNone.MouseDown

Select Case e.Button.ToString

Case "Left"
If e.Clicks = 2 Then Exit Sub '# Exits to Double
click
event
If tvNone.SelectedNode Is Nothing Then Exit Sub '#
Exits if nothing is selected

'# Enable Treeview that node can be dropped into
Me.tvNone.AllowDrop = True
Me.tvRFQ.AllowDrop = True
Me.tvEnquiry.AllowDrop = False
Me.tvEval.AllowDrop = False
Me.tvRPT.AllowDrop = False
Me.tvPO.AllowDrop = False
Me.tvRAS.AllowDrop = False
Me.tvITD.AllowDrop = False
Me.tvRAD.AllowDrop = False

'# Get Selected node and node index
Dim DraggedNode As String = tvNone.SelectedNode.Text
Dim DraggedNodeIndex As Integer =
tvNone.SelectedNode.Index

'# Send info to DragDrag events
tvNone.DoDragDrop(Chr(40) & DraggedNode & Chr(41) &
Chr(40) & 0 & Chr(41), DragDropEffects.Move)
'# Remove Selected Node
tvNone.Nodes.RemoveAt(DraggedNodeIndex)

Case "Middle"

Case "Right"

End Select

End Sub

Hi,
I'm not sure if you're clear enough for detailing your problem, but in
your code "e.clicks" counts the number of times that a button is
pressed, so if you want to determine the left button of mouse is
pressed, then you'd better change it as:

If e.Button = Windows.Forms.MouseButtons.Left Then
' Code.......
End If

... instead of select-case.

HTH,

Onur
 
B

Barkingmadscot

I am trying to find when the mouse left click is held down. I plan to
other stuff on the right clicks and possibly the middle clicks.

I plan to have different parts of my code doing different thing
depending on a double click, single click and click and hold (drag and
drop)

I have found when i select a node the mouseup event doesnt fire

if i select nothing both mousedown and mouseup events fire.

any thoughts
 
T

Thiago Macedo

I am trying to find when the mouse left click is held down. I plan to
other stuff on the right clicks and possibly the middle clicks.

I plan to have different parts of my code doing different thing
depending on a double click, single click and click and hold (drag and
drop)

I have found when i select a node the mouseup event doesnt fire

if i select nothing both mousedown and mouseup events fire.

any thoughts

thought: select on mouseup?
the focus change probally is causing the lost of mouseup.
 
C

Cor Ligthert[MVP]

Hi,

I have only seen this done with a little global boolean, which is set to
MouseButtonDown = true in the MouseDown event and set to false in the
MouseUp event.

Cor
 
B

Barkingmadscot

I had thought about a boolean, but the mouseup event(s) dont fire when
i select something, as suggested the focus is lost and would know when
the change the boolean back.

again i would use the mouseup event(s) but i have the same porblem
when selecting a node the mouseup does not fire, thus any code in the
event would happen.

If anyone has any other ideas, let me know, also if i work it out i
will let you know.
 
B

Barkingmadscot

Is there not anything like 'if mousebutton = true' (true being down
and false being up). i think the problem i have is focus changing
when i click, double click nodes etc.
 
L

Lloyd Sheen

Barkingmadscot said:
Is there not anything like 'if mousebutton = true' (true being down
and false being up). i think the problem i have is focus changing
when i click, double click nodes etc.


Control.MouseButtons

LS
 
Top