determinating if the mouse button is still down - again

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Barkingmadscot

    determinating if the mouse button is still down - again

    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_MouseDow n(ByVal sender As Object, ByVal e As
    System.Windows. Forms.MouseEven tArgs) Handles tvNone.MouseDow n


    Select Case e.Button.ToStri ng


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


    '# Enable Treeview that node can be dropped into
    Me.tvNone.Allow Drop = True
    Me.tvRFQ.AllowD rop = True
    Me.tvEnquiry.Al lowDrop = False
    Me.tvEval.Allow Drop = False
    Me.tvRPT.AllowD rop = False
    Me.tvPO.AllowDr op = False
    Me.tvRAS.AllowD rop = False
    Me.tvITD.AllowD rop = False
    Me.tvRAD.AllowD rop = False


    '# Get Selected node and node index
    Dim DraggedNode As String = tvNone.Selected Node.Text
    Dim DraggedNodeInde x As Integer =
    tvNone.Selected Node.Index


    '# Send info to DragDrag events
    tvNone.DoDragDr op(Chr(40) & DraggedNode & Chr(41) &
    Chr(40) & 0 & Chr(41), DragDropEffects .Move)
    '# Remove Selected Node
    tvNone.Nodes.Re moveAt(DraggedN odeIndex)


    Case "Middle"


    Case "Right"


    End Select


    End Sub
  • kimiraikkonen

    #2
    Re: determinating if the mouse button is still down - again

    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_MouseDow n(ByVal sender As Object, ByVal e As
    System.Windows. Forms.MouseEven tArgs) Handles tvNone.MouseDow n
    >
    Select Case e.Button.ToStri ng
    >
    Case "Left"
    If e.Clicks = 2 Then Exit Sub '# Exits to Double
    click
    event
    If tvNone.Selected Node Is Nothing Then Exit Sub '#
    Exits if nothing is selected
    >
    '# Enable Treeview that node can be dropped into
    Me.tvNone.Allow Drop = True
    Me.tvRFQ.AllowD rop = True
    Me.tvEnquiry.Al lowDrop = False
    Me.tvEval.Allow Drop = False
    Me.tvRPT.AllowD rop = False
    Me.tvPO.AllowDr op = False
    Me.tvRAS.AllowD rop = False
    Me.tvITD.AllowD rop = False
    Me.tvRAD.AllowD rop = False
    >
    '# Get Selected node and node index
    Dim DraggedNode As String = tvNone.Selected Node.Text
    Dim DraggedNodeInde x As Integer =
    tvNone.Selected Node.Index
    >
    '# Send info to DragDrag events
    tvNone.DoDragDr op(Chr(40) & DraggedNode & Chr(41) &
    Chr(40) & 0 & Chr(41), DragDropEffects .Move)
    '# Remove Selected Node
    tvNone.Nodes.Re moveAt(DraggedN odeIndex)
    >
    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.M ouseButtons.Lef t Then
    ' Code.......
    End If

    ... instead of select-case.

    HTH,

    Onur

    Comment

    • Barkingmadscot

      #3
      Re: determinating if the mouse button is still down - again

      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

      Comment

      • Thiago Macedo

        #4
        Re: determinating if the mouse button is still down - again

        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.

        Comment

        • Cor Ligthert[MVP]

          #5
          Re: determinating if the mouse button is still down - again

          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 " <barry@bcc-it.co.ukschreef in bericht
          news:3e267c21-ae8d-4d46-8f2a-7eef48cc1cce@2g 2000hsn.googleg roups.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_MouseDow n(ByVal sender As Object, ByVal e As
          System.Windows. Forms.MouseEven tArgs) Handles tvNone.MouseDow n
          >
          >
          Select Case e.Button.ToStri ng
          >
          >
          Case "Left"
          If e.Clicks = 2 Then Exit Sub '# Exits to Double
          click
          event
          If tvNone.Selected Node Is Nothing Then Exit Sub '#
          Exits if nothing is selected
          >
          >
          '# Enable Treeview that node can be dropped into
          Me.tvNone.Allow Drop = True
          Me.tvRFQ.AllowD rop = True
          Me.tvEnquiry.Al lowDrop = False
          Me.tvEval.Allow Drop = False
          Me.tvRPT.AllowD rop = False
          Me.tvPO.AllowDr op = False
          Me.tvRAS.AllowD rop = False
          Me.tvITD.AllowD rop = False
          Me.tvRAD.AllowD rop = False
          >
          >
          '# Get Selected node and node index
          Dim DraggedNode As String = tvNone.Selected Node.Text
          Dim DraggedNodeInde x As Integer =
          tvNone.Selected Node.Index
          >
          >
          '# Send info to DragDrag events
          tvNone.DoDragDr op(Chr(40) & DraggedNode & Chr(41) &
          Chr(40) & 0 & Chr(41), DragDropEffects .Move)
          '# Remove Selected Node
          tvNone.Nodes.Re moveAt(DraggedN odeIndex)
          >
          >
          Case "Middle"
          >
          >
          Case "Right"
          >
          >
          End Select
          >
          >
          End Sub

          Comment

          • Barkingmadscot

            #6
            Re: determinating if the mouse button is still down - again

            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.

            Comment

            • Barkingmadscot

              #7
              Re: determinating if the mouse button is still down - again

              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.

              Comment

              • Lloyd Sheen

                #8
                Re: determinating if the mouse button is still down - again


                "Barkingmadscot " <barry@bcc-it.co.ukwrote in message
                news:9225759a-ae1e-4fb6-a1ac-d648f273f7a8@x3 5g2000hsb.googl egroups.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.MouseBu ttons

                LS

                Comment

                Working...