With this callback and the Canvas gadget we could create custom gadgets that would be as easy to use as PBs own gadgets.
A callback procedure could then look like this (Pseudo-Code)
Code: Select all
Structure PB_EventData_AddGadgetItem ;This Structure would be Predefined by PB
Position.i
Text.s
ImageID.i
Flags.i
EndStructure
Structure PB_EventData_AddGadgetColumn ;This Structure would be Predefined by PB
Position.i
Title.s
Width.i
EndStructure
Structure PB_GadgetEventCallback_EventData ;This Structure would be Predefined by PB
StructureUnion
AddGadgetItem.PB_EventData_AddGadgetItem
AddGadgetColumn.PB_EventData_AddGadgetColumn
EndStructureUnion
EndStructure
Procedure GadgetEventCallback(#Gadget, EventType, *EventData.PB_GadgetEventCallback_EventData)
If EventType = #Event_LeftClick
;Depending on Mouse-Position Post a Custom Event
ElseIf EventType = #Event_AddGadgetItem
Select *EventData\AddGadgetItem\Position
Case -1
Case 0
Default
EndSelect
;Add a new item to the Custom Gadget or return Null if not possible for this Gadget
ElseIf EventType = #Event_GadgetHeight
ProcedureReturn #PB_ProcessPureBasicEvents ;Since PB knows the gadgets height we dont need to react on this event
ElseIf EventType = #Event_FreeGadget
;Do some Cleanup
EndIf
EndProcedure