the CanvasGadget will not send evnts, if the window style is #PB_Window_BorderLess or #PB_Window_Background
Code: Select all
OpenWindow(0, 0, 0, 320, 320, "Canvas container example", #PB_Window_BorderLess)
ContainerGadget(2, 0, 0, 320, 320)
CanvasGadget(0, 10, 10, 300, 300, #PB_Canvas_Container)
ButtonGadget(1, 10, 10, 80, 30, "Clean up")
CloseGadgetList()
CloseGadgetList()
Procedure GadgetEvents()
Select EventGadget()
Case 0
If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(0, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
If StartDrawing(CanvasOutput(0))
x = GetGadgetAttribute(0, #PB_Canvas_MouseX)
y = GetGadgetAttribute(0, #PB_Canvas_MouseY)
Circle(x, y, 10, RGB(Random(255), Random(255), Random(255)))
StopDrawing()
EndIf
EndIf
Case 1
If StartDrawing(CanvasOutput(0))
Box(0, 0, 300, 300, #White)
StopDrawing()
EndIf
EndSelect
EndProcedure
BindEvent(#PB_Event_Gadget, @GadgetEvents())