SG_ButtonGadget | |||||||||||||||||||||||||||||||||
Syntax: | |||||||||||||||||||||||||||||||||
Result=SG_ButtonGadget(SG_GadgetID_L.l, X_Pos_L.l, Y_Pos_L.l, Width_L.l, Height_L.l, GadgetText_S.s, [Flags_L.l]) | |||||||||||||||||||||||||||||||||
Parameters: | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
Return Values: | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
Description: | |||||||||||||||||||||||||||||||||
Create a button gadget in the current GadgetList. SG_GadgetID_L will be the number returned by SG_ScreenGadgetEvent() command. The following Events are supported: #SG_EventType_LeftClick : Left mouse button click. #SG_EventType_RightClick : Right mouse button click. #SG_EventType_LeftRelease : Left mouse button released. #SG_EventType_RightRelease : Right mouse button released. | |||||||||||||||||||||||||||||||||
Example: | |||||||||||||||||||||||||||||||||
; Shows possible flags of SG_ButtonGadget in action... If OpenWindow(0, 0, 0, 300, 200, #PB_Window_SystemMenu|#PB_Window_ScreenCentered,"SG_ButtonGadgets") And InitSprite() And InitMouse() And InitKeyboard() If OpenWindowedScreen(WindowID(), 0, 0, 300, 200, 0, 0, 0) SG_ButtonGadget(0, 10, 10, 200, 20, "Standard Button (quit)") SG_ButtonGadget(1, 10, 40, 200, 20, "Left Button", #PB_Button_Left) SG_ButtonGadget(2, 10, 70, 200, 20, "Right Button", #PB_Button_Right) SG_ButtonGadget(4, 10,170, 200, 20, "Toggle Button", #PB_Button_Toggle) ; create a mouse If CreateSprite(0, 8, 8) If StartDrawing(SpriteOutput(0)) Circle(4, 4, 4, RGB(255, 255, 255)) StopDrawing() EndIf EndIf Repeat ClearScreen(0, 0, 0) SG_DrawAllGadgets() ExamineMouse() DisplayTransparentSprite (0, MouseX(), MouseY()) FlipBuffers() ; standard loop Event = SG_ScreenGadgetEvent() ; This line checks if an event happened GadgetID = SG_EventScreenGadgetID() ; Is it a gadget event? EventType = SG_EventType() ; The event type If Event = #PB_EventGadget If GadgetID = 0 If EventType = #SG_EventType_LeftRelease Debug "button 0" SG_FreeAllGadgets() Event = #PB_Event_CloseWindow EndIf ElseIf GadgetID = 1 If EventType = #SG_EventType_LeftRelease Debug "button 1" EndIf ElseIf GadgetID = 2 If EventType = #SG_EventType_LeftRelease Debug "button 2" EndIf ElseIf GadgetID = 4 If EventType = #SG_EventType_LeftRelease Debug "button 4" EndIf EndIf EndIf Delay(1) Until WindowEvent() = #PB_Event_CloseWindow Or Event = #PB_Event_CloseWindow EndIf EndIf | |||||||||||||||||||||||||||||||||
Remarks: | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
|