[Gambas-user] Mouse Events

Matti math.eber at ...221...
Wed Oct 21 07:34:53 CEST 2009


Good idea, thanks.
I'll try that.

Werner schrieb:
> Matti wrote:
>> When I want to use a DblClick event on some controls that don't have the "Activate" event (eg PictureBox), I get difficulties:
>>
>> The MouseDown event is (of course) raised before the DblClick event.
>> So, before I can react to DblClick, I always land in MouseDown. Here I can tell if the mouse was pressed left or right and
>> everything, but I can't see if it is just the first click of a DblClick.
>>
>> I don't see a possibility to respond to a single-click on the control in one Sub, and to a double-click in another, because
>> there are always two events when there is a double-click.
>>
>> Any ideas?
>> Thanks, Matti
> You could try to knit your own doubleclick. All it needs is a timer.
> 
> Here is a pseudo code rough sketch:
> 
> 
> Event routine myControl_MouseDown:
> If myTimer is running
>     then
>        stop myTimer
>        #do your Double Click stuff here
>     else
>        start myTimer
>     end
> end # myControl_MouseDown
> 
> 
> Event routine myTimer_Timer:
> stop myTimer
> #do your single click stuff here
> end # myTimer_Timer
> 
> 
> You can then play with myTimer.Delay. Setting it to 1ms effectively
> disables double click. I think 300..400ms is a good number. Maybe the
> desktop of choice has a preference scheme where the user can set the delay.
> MyTimer.Enabled is initially false.
> 
> Regards
> Werner




More information about the User mailing list