cjinsocal581
asked on
Button press configuration in VB.NET
Here is something custom I am trying to do. Please let me know if it is even possible to do this.
When I press a button, it should operate normally.
But, when I press and hold the button for 2 seconds, pop a context menu with an option named "Reset"
Ideas?
When I press a button, it should operate normally.
But, when I press and hold the button for 2 seconds, pop a context menu with an option named "Reset"
Ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Second solution worked the way I needed. Thanks for the effort to both.
I'm not near VS.NET but here is how i think it should work.
Imports System.Threading
Private timerThread As Thread
Private cancelThread As Boolean = False
Private Sub DelayedPopup()
Thread.Sleep(2000)
If cancelThread = False Then
ContextMenu.Show()
End If
End Sub
Private Sub Button1_MouseDown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.MouseDown
timerThread = New Thread(New ThreadStart(AddressOf DelayedPopup))
timerThread.Start
cancelThread = False
End Sub
Private Sub Button1_MouseUp(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.MouseUp
timerThead = Nothing
cancelThread = True
End Sub
That should do it. Not sure if it works because right now I'm on linux. But that concept will work
Hope That Helps
Matt