Results 1 to 3 of 3

Thread: Right mouse on Nodeview_click

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Location
    flanders, nj 07836
    Posts
    110

    Question

    Hello all! Just looking for simple code that will let me discern whether the user used the left or right mouse button (or middle for that matter) in a WHATEVERNODE_NodeClick() event. You would think Microsoft would just add a button reference like there is in the mousedown event, but WHY MAKE THINGS EASY!

    Thanks to whoever answers.

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Lightbulb Use MouseDown event

    Node click doesn't care what button you clicked with. What you can do is to use a MouseDown event to check if the user clicked with the right mouse button.
    Code:
    Private Sub TreeView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
        Dim nodCurrent As Node
        
        If Button = vbRightButton Then
            Set nodCurrent = TreeView1.HitTest(x, y)
            If Not nodCurrent Is Nothing Then
                nodCurrent.Selected = True
                MsgBox "You right clicked on " & nodCurrent.Text
            End If
        End If
    End Sub

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Talking

    I remember this pattern. You can use this one, it fires only if you click on a node.
    Code:
    Private Sub TreeView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
        TreeView1.Tag = Button
    End Sub
    Private Sub TreeView1_NodeClick(ByVal Node As ComctlLib.Node)
        Select Case TreeView1.Tag
            Case 1
                'Left button code here
            Case 2
                'Right button code here
        End Select
    End Sub
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width