# SUIDropdown

**الأعضاء** 22

|       |                                         |                                                                                                                                                                                                                                                   |
| ----- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| دالة  | [RefreshShownValue](#refreshshownvalue) | Refreshes the text and image (if available) of the currently selected option.If you have modified the list of options, you should call this method afterwards to ensure that the visual state of the dropdown corresponds to the updated options. |
| دالة  | [AddOptions](#addoptions)               | Add multiple options to the options of the Dropdown.                                                                                                                                                                                              |
| دالة  | [ClearOptions](#clearoptions)           | Clear the list of options in the Dropdown.                                                                                                                                                                                                        |
| دالة  | [Show](#show)                           | Show the dropdown list.                                                                                                                                                                                                                           |
| دالة  | [Hide](#hide)                           | Hide the dropdown list.                                                                                                                                                                                                                           |
| دالة  | [OnValueChanged](#onvaluechanged)       | Bind a function to handle the event that is invoked when when a user has clicked one of the options in the dropdown list.                                                                                                                         |
| دالة  | [SetValueByText](#setvaluebytext)       | Attempts to set the dropdown to the first option in the dropdown list that matches the inputted text.                                                                                                                                             |
| خاصية | [Interactable](#interactable)           | Is this UIDropdown interactable?                                                                                                                                                                                                                  |
| خاصية | [Template](#template)                   | The Rect Transform of the template for the dropdown list.                                                                                                                                                                                         |
| خاصية | [CaptionText](#captiontext)             | The Text component to hold the text of the currently selected option.                                                                                                                                                                             |
| خاصية | [CaptionImage](#captionimage)           | The Image component to hold the image of the currently selected option.                                                                                                                                                                           |
| خاصية | [ItemText](#itemtext)                   | The Text component to hold the text of the item.                                                                                                                                                                                                  |
| خاصية | [ItemImage](#itemimage)                 | The Image component to hold the image of the item.                                                                                                                                                                                                |
| خاصية | [OptionsAsText](#optionsastext)         | The list of possible options. (Text)                                                                                                                                                                                                              |
| خاصية | [OptionsAsSprites](#optionsassprites)   | The list of possible options. (Sprites)                                                                                                                                                                                                           |
| خاصية | [Value](#value)                         | The Value is the index number of the current selection in the Dropdown. 0 is the first option in the Dropdown, 1 is the second, and so on.                                                                                                        |
| خاصية | [NormalColor](#normalcolor)             | –                                                                                                                                                                                                                                                 |
| خاصية | [HighlightedColor](#highlightedcolor)   | –                                                                                                                                                                                                                                                 |
| خاصية | [PressedColor](#pressedcolor)           | –                                                                                                                                                                                                                                                 |
| خاصية | [DisabledColor](#disabledcolor)         | –                                                                                                                                                                                                                                                 |
| خاصية | [ColorMultiplier](#colormultiplier)     | –                                                                                                                                                                                                                                                 |
| خاصية | [GameObject](#gameobject)               | –                                                                                                                                                                                                                                                 |

## الدوال

### RefreshShownValue

void RefreshShownValue()

Refreshes the text and image (if available) of the currently selected option.If you have modified the list of options, you should call this method afterwards to ensure that the visual state of the dropdown corresponds to the updated options.

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIDropdown.RefreshShownValue()

```

### AddOptions

void AddOptions(string\[] options)

void AddOptions(Table options)

void AddOptions([SResource](/docs/ar/scripting/client-scripting-api-reference/types/sresource.md)\[] optionsSprites)

Add multiple options to the options of the Dropdown.

المعاملات

| الاسم          | النوع                                                                                | القيمة الافتراضية |
| -------------- | ------------------------------------------------------------------------------------ | ----------------- |
| options        | string\[]                                                                            | –                 |
| options        | Table                                                                                | –                 |
| optionsSprites | [SResource](/docs/ar/scripting/client-scripting-api-reference/types/sresource.md)\[] | –                 |

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIDropdown.AddOptions({"option1","option2","option3"})

```

### ClearOptions

void ClearOptions()

Clear the list of options in the Dropdown.

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIDropdown.ClearOptions()

```

### Show

void Show()

Show the dropdown list.

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIDropdown.Show()

```

### Hide

void Hide()

Hide the dropdown list.

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIDropdown.Hide()

```

### OnValueChanged

void OnValueChanged(Closure callback)

Bind a function to handle the event that is invoked when when a user has clicked one of the options in the dropdown list.

المعاملات

| الاسم    | النوع   | القيمة الافتراضية |
| -------- | ------- | ----------------- |
| callback | Closure | –                 |

القيم المرجعة

`void`

مثال

**Lua**

```lua
function AFunction()
--
end

Space.Host.ExecutingObject.UIDropdown.OnValueChanged(AFunction)

```

### SetValueByText

bool SetValueByText(string text)

Attempts to set the dropdown to the first option in the dropdown list that matches the inputted text. Returns true if found, false if no matches found.

المعاملات

| الاسم | النوع  | القيمة الافتراضية |
| ----- | ------ | ----------------- |
| text  | string | –                 |

القيم المرجعة

`bool`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIDropdown.SetValueByText("Value Text")

```

**Lua**

```lua
--Populating a UIDropdown and making a selection using value's text
dropDown=Space.Host.GetReference("DropDown").UIDropdown
options = {"Room 1", "Room 2", "Room 3", "Room 4"}
dropDown.AddOptions(options)
dropDown.SetValueByText("Room 3")

```

## الخصائص

### Interactable

bool Interactable {get; set; }

Is this UIDropdown interactable?

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIDropdown.Interactable = true

```

**Lua**

```lua
--clicking this object will toggle a UIDropdown's interactable status

thisGameObject = Space.Host.ExecutingObject
dropdown = Space.Host.GetReference("dropdown").UIDropdown 
--make sure to add this reference to the Scripting Runtime component


OnClick = function()
dropdown.Interactable =  not dropdown.Interactable
end


thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)

```

### Template

[SGameObject](/docs/ar/scripting/client-scripting-api-reference/types/sgameobject.md) Template {get; set; }

The Rect Transform of the template for the dropdown list.

مثال

**Lua**

```lua
aReferenceToAGameObject = Space.Host.GetReference("reference name")
Space.Host.ExecutingObject.UIDropdown.Template = aReferenceToAGameObject

```

### CaptionText

[SUIText](/docs/ar/scripting/client-scripting-api-reference/components/suitext.md) CaptionText {get; set; }

The Text component to hold the text of the currently selected option.

مثال

**Lua**

```lua
captionText = Space.Host.ExecutingObject.UIDropdown.CaptionText
captionText.Text = "new caption"

```

### CaptionImage

[SUIImage](/docs/ar/scripting/client-scripting-api-reference/components/suiimage.md) CaptionImage {get; set; }

The Image component to hold the image of the currently selected option.

مثال

**Lua**

```lua
aReferenceToAGameObject = Space.Host.GetReference("reference name")
Space.Host.ExecutingObject.UIDropdown.CaptionImage = aReferenceToAGameObject.UIImage

```

### ItemText

[SUIText](/docs/ar/scripting/client-scripting-api-reference/components/suitext.md) ItemText {get; set; }

The Text component to hold the text of the item.

مثال

**Lua**

```lua
aReferenceToAGameObject = Space.Host.GetReference("reference name")
Space.Host.ExecutingObject.UIDropdown.CaptionImage = aReferenceToAGameObject.UIText

```

### ItemImage

[SUIImage](/docs/ar/scripting/client-scripting-api-reference/components/suiimage.md) ItemImage {get; set; }

The Image component to hold the image of the item.

مثال

**Lua**

```lua
iaReferenceToAGameObject = Space.Host.GetReference("reference name")
Space.Host.ExecutingObject.UIDropdown.CaptionImage = aReferenceToAGameObject.UIImage

```

### OptionsAsText

string\[] OptionsAsText {get; }

The list of possible options. (Text)

مثال

**Lua**

```lua
optionsText = Space.Host.ExecutingObject.UIDropdown.OptionsAsText

```

### OptionsAsSprites

[SResource](/docs/ar/scripting/client-scripting-api-reference/types/sresource.md)\[] OptionsAsSprites {get; }

The list of possible options. (Sprites)

مثال

**Lua**

```lua
optionsSprites = Space.Host.ExecutingObject.UIDropdown.OptionsAsSprites

```

### Value

int Value {get; set; }

The Value is the index number of the current selection in the Dropdown. 0 is the first option in the Dropdown, 1 is the second, and so on.

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIDropdown.Value= 2

```

### NormalColor

[SColor](/docs/ar/scripting/client-scripting-api-reference/types/scolor.md) NormalColor {get; set; }

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIDropdown.NormalColor = Color.Red

```

### HighlightedColor

[SColor](/docs/ar/scripting/client-scripting-api-reference/types/scolor.md) HighlightedColor {get; set; }

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIDropdown.HighlightedColor = Color.Red

```

### PressedColor

[SColor](/docs/ar/scripting/client-scripting-api-reference/types/scolor.md) PressedColor {get; set; }

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIDropdown.PressedColor = Color.Red

```

### DisabledColor

[SColor](/docs/ar/scripting/client-scripting-api-reference/types/scolor.md) DisabledColor {get; set; }

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIDropdown.DisabledColor = Color.Red

```

### ColorMultiplier

float ColorMultiplier {get; set; }

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIDropdown.ColorMultiplier = Color.Red

```

### GameObject

[SGameObject](/docs/ar/scripting/client-scripting-api-reference/types/sgameobject.md) GameObject {get; }

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIDropdown.GameObject = Color.Red

```
