I just found out that the mouse wheel is not detected (#PB_EventType_MouseWheel) when using the #PB_Canvas_Container flag in a Canvas Gadget. I modified the Canvas Gadget example from the PureBasic manual to show this:
Code: Select all
If OpenWindow(0, 0, 0, 220, 220, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
; This works:
CanvasGadget(0, 10, 10, 200, 200)
; This doesn't work:
;CanvasGadget(0, 10, 10, 200, 200, #PB_Canvas_Container)
;CloseGadgetList()
Color=RGB(Random(255), Random(255), Random(255))
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget And EventGadget() = 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, Color)
StopDrawing()
EndIf
ElseIf EventType() = #PB_EventType_MouseWheel
z = GetGadgetAttribute(0, #PB_Canvas_WheelDelta)
If z<>0
Color=RGB(Random(255), Random(255), Random(255))
EndIf
Debug "Wheel!"
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
Tested on Ubuntu 20.04, PB 5.73 and PB 6.00.