SG_ComboBoxGadget | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Syntax: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Result=SG_ComboBoxGadget(SG_GadgetID_L, X_Pos_L, Y_Pos_L, Width_L, Height_L [, Flags_L]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Return Values: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Create a combobox gadget in the current GadgetList. #Gadget will be the number returned by SG_EventGadgetID() command. - SG_GetGadgetState() can be used to get the current gadget state (what item is selected) or -1 for none. - SG_SetGadgetState() can be used to change the gadget state (select an item) or -1 for none. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Example: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#ComboBox0 = 0 If Not InitSprite() Or Not InitMouse() Or Not InitKeyboard() End EndIf If OpenWindow(1, 0, 0, 1024, 768, "Screen Gadget ComboBox", #PB_Window_BorderLess) If OpenWindowedScreen(WindowID(1), 0,0, 1024, 768, 0, 0, 0) ; create a mouse If CreateSprite(0, 8, 8) If StartDrawing(SpriteOutput(0)) Circle(4, 4, 4, RGB(255, 255, 255)) StopDrawing() EndIf EndIf SG_ComboBoxGadget(#ComboBox0, 700, 500, 200, 150) For x = 0 To 15 SG_AddGadgetItem(#ComboBox0, -1, "Test " + Str(x)) Next SG_AddGadgetItem(#ComboBox0, 2, "test insert at pos 2" + Str(x)) SG_SetGadgetItemColor(#ComboBox0, 3, $00FF00, $FF00FF) Repeat ClearScreen(0) SG_DrawGadgets() ExamineMouse() DisplayTransparentSprite(0, MouseX(), MouseY()) FlipBuffers() Event = SG_ScreenGadgetEvent() ; This line checks if an event happened and resolve the mouse actions with the gadgets GadgetID = SG_EventScreenGadgetID() ; Is it a gadget event? EventType = SG_EventType() ; The event type If Event = #PB_Event_Gadget And EventType = #SG_EventType_LeftRelease If GadgetID = #ComboBox0 Debug SG_GetGadgetState(#ComboBox0) EndIf EndIf Until WaitWindowEvent() = #PB_Event_CloseWindow EndIf EndIf End | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Remarks: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|