By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,186 Members | 1,620 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,186 IT Pros & Developers. It's quick & easy.

determinating if the mouse button is still down - again

P: n/a
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
Jun 27 '08 #1
Share this Question
Share on Google+
7 Replies


P: n/a
On Apr 23, 3:10 pm, Barkingmadscot <ba...@bcc-it.co.ukwrote:
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
Jun 27 '08 #2

P: n/a
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

Jun 27 '08 #3

P: n/a
On 23 abr, 09:26, Barkingmadscot <ba...@bcc-it.co.ukwrote:
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.
Jun 27 '08 #4

P: n/a
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

"Barkingmadscot" <ba***@bcc-it.co.ukschreef in bericht
news:3e**********************************@2g2000hs n.googlegroups.com...
>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
Jun 27 '08 #5

P: n/a
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.
Jun 27 '08 #6

P: n/a
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.
Jun 27 '08 #7

P: n/a

"Barkingmadscot" <ba***@bcc-it.co.ukwrote in message
news:92**********************************@x35g2000 hsb.googlegroups.com...
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

Jun 27 '08 #8

This discussion thread is closed

Replies have been disabled for this discussion.