Page 1 of 1

CustomGadgetFunction & CustomGadgetType

Posted: Sat Jan 28, 2017 10:40 am
by eddy
Hi,
I read this topic "ownGadget"
I wonder if it's possible to make custom pb gadget easier.
This could be done like that in PB :

Code: Select all

OpenWindow(0, 0, 0, 220, 220, "FancyButton", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
FancyButton = CanvasGadget(0, 10, 10, 200, 200) 
// to extend or customize a gadget behavior
originalSetGadgetType = CustomGadgetType(FancyButton, #PB_GadgetType_Unknown + 100)
*originalSetGadgetState = CustomGadgetFunction(FancyButton, #PB_CustomGadget_SetGadgetState,  @SetFancyButtonState()) 
*originalSetGadgetText = CustomGadgetFunction(FancyButton, #PB_CustomGadget_SetGadgetText,  @SetFancyButtonText()) 

// to restore or use original gadget behavior
CustomGadgetType(FancyButton, originalSetGadgetType)
CustomGadgetFunction(FancyButton, #PB_CustomGadget_SetGadgetState,  *originalSetGadgetState) 
CustomGadgetFunction(FancyButton, #PB_CustomGadget_SetGadgetText,  *originalSetGadgetText)