views:

62

answers:

1

In my application I catch a DragOver event and then perform an action. I'd like to wait for half a second before performing the action, the action should not be performed after that delay if the drag operation has ended.

The only way I could think of to implement this feature is something like this:

Function DragOver Event
   If TimerTimeReached Then
      PerformDragAction
   Else If Not TimerStarted
      StartTimer
   End
End Function  

Function DragLeave Event
   If TimerStarted
      StopTimer
   End
End Function

Is there a better way to perform this operation?

+1  A: 

It looks OK, but does the DragOver event happen multiple times?

I think the PerformDragAction should move to a Timer event handler.

Henk Holterman
The DragOver not happening after the timer is reached is not a big issue. The user is very likely to move the mouse instead of remaining stationary but it would be nice to make this works even if the event is not fired repeatedly. I'll probably automatically fire the event with a timer callback when the delay is reached, it also needs to continue performing the drag action if the user is still dragging.