[Implemented] CanvasGadget - mouse clicks
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
[Implemented] CanvasGadget - mouse clicks
It would be good for the canvas gadget to get mouseclick and doubleclick events - this way you can make a custom gadget react properly for a doubleclick. (some users may change the speed of double-clicks).
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
Re: CanvasGadget - mouse clicks
I wonder if it could be add. Because of the mouse up event, and the mouse down event, the click is decomposed into 2 events. Doing a third one would be a pretty time loss.
Just add something ^^ :
check the debugger output for the image gadget and the canvasgadget : it react in the same way :
Just add something ^^ :
check the debugger output for the image gadget and the canvasgadget : it react in the same way :
Code: Select all
If OpenWindow(0, 0, 0, 400, 300, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
CanvasGadget(0, 10, 10, 380, 135, #PB_Canvas_Keyboard)
ImageGadget(1, 10, 155, 380, 135, 0)
StartDrawing(CanvasOutput(0))
Box(0, 0, GadgetWidth(0), GadgetHeight(0), 0)
StopDrawing()
Else
End
EndIf
Repeat
event = WaitWindowEvent()
If event = #PB_Event_Gadget
Select EventGadget()
Case 0
Select EventType()
Case #PB_EventType_MouseEnter
Mouse_button_had_been_down = #False
Case #PB_EventType_LeftButtonDown
Mouse_button_had_been_down = #True
Case #PB_EventType_LeftButtonUp
If Mouse_button_had_been_down
Mouse_button_had_been_down = #False
If ElapsedMilliseconds() - Mouse_button_double_click_time < 200 ; <----- HERE ajust the Double click time
;{ DOUBLE CLICK
Debug "CANVASGADGET : double click"
; for a double click you just add a counter !
;}
EndIf
Mouse_button_double_click_time = ElapsedMilliseconds()
;{ CLICK
Debug "CANVASGADGET : click"
; here you it's has if the user had clicked !!
; you can even specifie a timeout for the click, and other parameters.
;}
EndIf
EndSelect
Case 1
Select EventType()
Case #PB_EventType_LeftClick
Debug "IMAGEGADGET : click"
Case #PB_EventType_LeftDoubleClick
Debug "IMAGEGADGET : Double click"
EndSelect
EndSelect
EndIf
Until event = #PB_Event_CloseWindow
End
_________________________________________________
My Website : CeriseCode (Warning : perpetual changes & not completed
)
My Website : CeriseCode (Warning : perpetual changes & not completed

- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Re: CanvasGadget - mouse clicks
Graph100: Thanks for the code
Derren: Thanks for the link

Derren: Thanks for the link

https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
Re: CanvasGadget - mouse clicks
Speaking of custom Gadget, you can go see there : Custom gadget 

_________________________________________________
My Website : CeriseCode (Warning : perpetual changes & not completed
)
My Website : CeriseCode (Warning : perpetual changes & not completed

- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Re: CanvasGadget - mouse clicks
Graph100: That's a great link. Thanks. 
It's a shame that the PB scrollbars don't give live event data as this would have made it so that you didn't have to use custom ones in the 'custom gadget' code (in the link).

It's a shame that the PB scrollbars don't give live event data as this would have made it so that you didn't have to use custom ones in the 'custom gadget' code (in the link).
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
Re: CanvasGadget - mouse clicks
yes, that's a shame, but with that I can tweak my gadget too the extreme 
this would allow to create entire UI with the same colour theme. If someone is motivated enough, the look of the gadget can easily be redesigned
because the operating is separated of the look.
even though it is in French, I hope you find it interesting ^^. In the beginning I started coding and wrote the comment in French, but It's quite difficult to think in a another language.
Maybe, when I would have advance a little more, I will translate all the comments French / English.
If you have any suggestion, please post them, even in English
I'm pretty reluctant to post on the English forum with a code not too advanced. (And maintaining 2 post about the same subject is pretty tiring)

this would allow to create entire UI with the same colour theme. If someone is motivated enough, the look of the gadget can easily be redesigned

because the operating is separated of the look.
even though it is in French, I hope you find it interesting ^^. In the beginning I started coding and wrote the comment in French, but It's quite difficult to think in a another language.
Maybe, when I would have advance a little more, I will translate all the comments French / English.
If you have any suggestion, please post them, even in English

_________________________________________________
My Website : CeriseCode (Warning : perpetual changes & not completed
)
My Website : CeriseCode (Warning : perpetual changes & not completed

- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Re: CanvasGadget - mouse clicks
Thanks. 

https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system