CustomGadgetFunction & CustomGadgetType

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

CustomGadgetFunction & CustomGadgetType

Post 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) 

Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool