SG_ComboBoxGadget

Syntax:

Result=SG_ComboBoxGadget(SG_GadgetID_L, X_Pos_L, Y_Pos_L, Width_L, Height_L [, Flags_L])

Parameters:

SG_GadgetID_L

=

The number of the gadget

X_Pos_L

=

the x-position of the gadget

Y_Pos_L

=

the y position of the gadget

Width_L

=

the width of the gadget

Height_L

=

the height of the gadget

[Flags_L]

=

'Flags' are always optional and can be composed of one or several (using the bitwise OR operator '|') of the following constants:

#PB_ComboBox_LowerCase

=

#PB_ComboBox_UpperCase

=

the following functions work with the ComboBox gadget

=

- AddGadgetItem(): add an item

=

- GetGadgetItemText(): returns the item text

=

- CountGadgetItems(): count the items of the gadget

=

- ClearGadgetItemList(): clear all items

=

- RemoveGadgetItem(): remove the item

=

- SetGadgetItemText(): change the text of the item

=

- SG_SetGagdetBackgroundImage()

=

- SG_SetGagdetBackgroundColor()

=

- SG_SetGagdetItemColor()

=

- GetGadgetState(): returns the current item

=

- GetGadgetText(): returns the text of the current item

=

- SetGadgetState(): change the current item

=

EndWith

=


Return Values:

Result

=

contains a pointer to the internal gadget structur. See the source of this lib for more information


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:



Supported OS:   Windows