DreamGUI
类参考

UDreamDropdown

A dropdown whose hierarchy is code, not an asset.

本页由 DreamGUIReferenceDocs commandlet 从反射生成,正文是头文件注释的原文(英文),所以不翻译——这样它永远和代码一致。概念讲解见核心概念。

Inherits from UDreamUIControl.

Declared in Public/Controls/DreamDropdown.h.

A dropdown whose hierarchy is code, not an asset.

The largest of the preset Blueprints -- sixteen widgets -- reduced to what UUIDropdown actually reads: a face with a caption, a list root that Show() positions and animates, and inside it a content column holding one templated row. The behaviour duplicates that row per option, so the template is authored once, inactive, and never drawn itself.

The row carries the toggle arrangement the library keeps arriving at: hover tints the row's own face, the selection mark is a separate visual, because one visual cannot hold two transitions.

Options are plain texts here rather than the behaviour's text+brush pairs: the common case, and the control's job is to be the common case. A consumer needing per-option icons talks to DropdownBehaviour directly.

Where there is no tween manager to fade the list -- a world with no game instance, which is the designer's preview and a headless test -- it opens and closes at once, at its end opacity, rather than waiting on a fade that will never run.

Properties

NameTypeCategoryIn the details panelFrom BlueprintDescription
StyleFDreamDropdownStyleDropdownyesGetStyle / SetStyleThis instance's own look. The project sheet wins while StyleSource says so AND a sheet actually exists; with no sheet in the project this IS the look in effect -- which is why it stays editable instead of being gated on the enum: the old edit condition greyed the exact values that were driving the control.
OptionsTArray<FText>DropdownyesGetOptions / SetOptionsBlueprintReadOnly rather than a BlueprintSetter pair, and for the reason UDreamDialog::Buttons is: the options are what the open list is BUILT from, so a Blueprint writing this array in place changed the data and left the list showing the old copy. SetOptions is the way in. The designer and .dui still author it directly, where PostEditChangeProperty re-pushes.
SelectedIndexint32DropdownyesGetSelectedIndex / SetSelectedIndexAuthored selection in; mirror of the behaviour's out. -1 is none.
MaxVisibleItemsint32DropdownyesGetMaxVisibleItems / SetMaxVisibleItemsHow many rows the open list shows at most. The list is always exactly as tall as its visible rows -- rows-times-row-height, no more -- and past this many the rest scroll: the cap is a count because that is how a designer thinks about a dropdown, not in pixels.
OptionIconsTArray<TObjectPtr<UObject> >DropdownyesSetOptionIconsA picture per option, index-matched to Options -- the same parallel-array idiom TabLabels and TabEnabled use, and for the same reason: a struct per option would make the common case (no icons at all) cost an array literal the language cannot write.
bHasDownArrowboolDropdownyesGetHasDownArrow / SetHasDownArrowWhether the face draws its own arrow glyph -- UMG's HasDownArrow. Off is for a face that says "open me" some other way (an icon of its own, a border).
bTabCommitsHighlightedRowboolDropdownyesGetTabCommitsHighlightedRow / SetTabCommitsHighlightedRowTab or Shift+Tab in the open list chooses the row the player is on, then the list closes and the Tab moves on past the dropdown -- what an HTML select does. Off, Tab only closes the list and chooses nothing. Tab never walks the rows: the arrow keys and the pad do that.
ItemTemplateClassTSubclassOf<UDreamUserWidget>DropdownyesGetItemTemplateClass / SetItemTemplateClassAn option row's CONTENT, authored elsewhere: one instance of this class is created inside every item widget, filling it, and the built-in label steps aside. The row's face, its check mark, its hover and its selection stay the control's, so a template only has to draw an option.
FaceNodeTObjectPtr<UDreamWidget>Dropdown-read only
CaptionNodeTObjectPtr<UDreamWidget>Dropdown-read only
ArrowNodeTObjectPtr<UDreamWidget>Dropdown-read only
ListNodeTObjectPtr<UDreamWidget>Dropdown-read only
ItemTemplateNodeTObjectPtr<UDreamWidget>Dropdown-read only
DropdownBehaviourTObjectPtr<UUIDropdown>Dropdown-read only

Functions

FunctionKindDescription
void AddOption(FText InOption)callableThe option list, one call at a time -- UMG's combo box API, which is what a screen building its options from game data actually uses.
void ClearOptions()callableThe options and their icons, both. The selection is ClearSelection's business, not this one's.
void ClearSelection()callableSelects nothing at all -- index -1, which is what the control already spells "none".
int32 FindOptionIndex(FText InOption)pureCompared by MEANING (FText::EqualTo), so a localized option matches across cultures. -1 for none.
bool GetHasDownArrow()pureGet Has Down Arrow
TSubclassOf<UDreamUserWidget> GetItemTemplateClass()pureGet Item Template Class
int32 GetMaxVisibleItems()pureGet Max Visible Items
FText GetOptionAtIndex(int32 InIndex)pureEmpty text for an index nobody offers, rather than a read off the end.
int32 GetOptionCount()pureGet Option Count
TArray<FText> GetOptions()pureGet Options
int32 GetSelectedIndex()pureGet Selected Index
FText GetSelectedOption()pureThe selected option's text, or empty while nothing is selected.
FDreamDropdownStyle GetStyle()pureGet Style
bool GetTabCommitsHighlightedRow()pureGet Tab Commits Highlighted Row
bool IsOpen()pureWhether the list is up. Mirrored from the behaviour's own visibility seam rather than kept by whoever opened it, so a list closed by a click elsewhere is not still "open" here.
void RefreshOptions()callableRebuild the rows from the current options. For a caller who edited the array in place.
bool RemoveOption(FText InOption)callableFalse when no option matched, as UMG's returns. Takes the matching icon with it.
void SetHasDownArrow(bool bInHasDownArrow)callableSet Has Down Arrow
void SetItemTemplateClass(TSubclassOf<UDreamUserWidget> InItemTemplateClass)callableRebuilds the rows: what a row IS comes from this class, so a bare write would change nothing.
void SetMaxVisibleItems(int32 InMaxVisibleItems)callableHow many rows the open list shows at most, re-pushed at once.
void SetOptionIcons(TArray<UObject*> InIcons)callableReplace the per-option pictures and re-push the list, so an open one changes under the pointer.
void SetOptions(TArray<FText> InOptions)callableReplace the options: an open list is rebuilt and re-placed at once, a closed one when it next opens.
void SetSelectedIndex(int32 InIndex)callableSet Selected Index
void SetSelectedOption(FText InOption)callableSelects the option with that text. An option nobody offers changes nothing.
void SetStyle(FDreamDropdownStyle InStyle)callableThis instance's whole look, replaced and pushed. See UDreamButton::SetStyle for the caveat.
void SetTabCommitsHighlightedRow(bool bInTabCommitsHighlightedRow)callableSee bTabCommitsHighlightedRow. Pushed to the behaviour at once, so an open list answers the next Tab by it.

Events

EventSignatureDescription
OnSelectionChangedvoid DreamDropdownChangedEvent__DelegateSignature(int32 SelectedIndex)Re-broadcast from the behaviour, so a consumer binds to the control, not to a part of it.
OnOpeningvoid DreamDropdownSimpleEvent__DelegateSignature()The list is opening -- UMG's OnOpening, and the moment to refresh the options from.
OnClosedvoid DreamDropdownSimpleEvent__DelegateSignature()The list closed, whether by a choice or by a click elsewhere.
OnValueChangedBPvoid DreamDropdownChangedEvent__DelegateSignature(int32 SelectedIndex)The <-> convention: two-way bindings synthesize their reverse route against this exact name, so a value control carries it alongside its spoken events. Fires with them.
OnItemGeneratedvoid DreamDropdownItemEvent__DelegateSignature(int32 ItemIndex, UDreamWidget* Item)One per option row, as the list is built. The hook for a consumer whose options are richer than a word but who would rather not author a whole class: everything under the row is reachable from here by display name. The dropdown's counterpart of the list's OnRowGenerated.

Compared with UMG

Every Blueprint-facing member of the UMG class, and where it went. adopt: same name, same meaning. map: here under another name or on another type. reject: deliberately absent, with the reason.

UMGMemberStatusHereNote
UComboBoxStringDefaultOptionsmapOptionsOne array, not two. UMG keeps DefaultOptions beside a runtime list because its combo box rebuilds from the Slate widget's own copy; here the rows are built from Options on every push, so the authored array IS the live one.
UComboBoxStringSelectedOptionmapSelectedIndexThe index is the authored truth and the option text follows from it (GetSelectedOption / SetSelectedOption). Two authored spellings of one selection is how an array edit leaves them disagreeing.
UComboBoxStringWidgetStylemapStyleFDreamDropdownStyle: the face's five state colours and brush, the list's background, the rows, the check mark and the caption.
UComboBoxStringItemStylemapFDreamDropdownStyle::ItemBrushA row's look is part of the dropdown's own style rather than a separate table-row style: ItemBrush, ItemHeight, ItemHovered, ItemFocused, ItemDisabled and CheckColor beside it.
UComboBoxStringScrollBarStylerejectThere is no bar to style. This dropdown's open list is exactly MaxVisibleItems tall and scrolls by wheel and drag with no bar drawn -- a list capped at a row count is always the size it looks, which is what makes the bar unnecessary rather than missing. The family's bar style is FDreamScrollBarStyle and its control is Native.ScrollBar; a list that wants one is a Native.ScrollBox, not a combo box.
UComboBoxStringContentPaddingmapFDreamDropdownStyle::ContentPaddingIn the style, and its default is what the control has always arranged down to the number (ten left, twenty-four right to clear the arrow). Stating it makes a wider face, or a face with no arrow, something a project sheet can answer.
UComboBoxStringMaxListHeightmapMaxVisibleItemsA row COUNT rather than a pixel height, because that is how a designer thinks about a dropdown; the open list is exactly count-times-ItemHeight tall and the rest scroll.
UComboBoxStringHasDownArrowmapbHasDownArrowNamed with this codebase's bool prefix.
UComboBoxStringEnableGamepadNavigationModerejectA switch between two behaviours, of which only one exists here -- and it is the one the flag turns ON. An open list's rows are ordinary selectables: a direction moves focus and commits nothing until the row is activated, which is exactly UMG's gamepad navigation mode. The OFF state, where a direction on the CLOSED control changes the value without opening it, has no counterpart and should not gain one: a closed control that eats left and right is the trap UUISlider::RequiresControllerLock exists to keep a row of controls out of.
UComboBoxStringFontmapFDreamDropdownStyle::FontSizeA size, not an FSlateFontInfo: the typeface is the text visual's own (UDreamText), and what a dropdown's style decides is how big its caption and rows are.
UComboBoxStringForegroundColormapFDreamDropdownStyle::TextColorThe caption's and the rows' colour. FDreamUIStateFaces beside it carries a per-state foreground for a face that wants its caption to change with the pointer.
UComboBoxStringbIsFocusablemapUDreamWidget::bIsFocusableEvery widget here carries it.
UComboBoxStringOnGenerateWidgetEventmapItemTemplateClassA CLASS rather than a per-row delegate, with OnItemGenerated fired for each row to fill it. Same bargain as UDreamListViewBase::RowTemplateClass: a class is something .dui and the designer can name, and a delegate is not.
UComboBoxStringOnSelectionChangedmapOnSelectionChangedCarries the index. UMG's second argument, ESelectInfo, has no counterpart: the behaviour raises one value-changed seam whatever moved the value, so 'who changed it' is not a question this control can answer honestly.
UComboBoxStringOnOpeningadoptOnOpeningFired from the behaviour's Show, before the rows are placed -- so options written from a handler are the ones the player sees. OnClosed is the pair UMG has no name for.
UComboBoxStringAddOptionadoptAddOptionFText rather than FString: an option is something a player reads, and this framework carries FText all the way.
UComboBoxStringRemoveOptionadoptRemoveOptionTakes the index-matched icon with it.
UComboBoxStringFindOptionIndexadoptFindOptionIndexCompares by meaning (FText::EqualTo), so a localized option matches across cultures.
UComboBoxStringGetOptionAtIndexadoptGetOptionAtIndexEmpty text for an index nobody offers.
UComboBoxStringClearOptionsadoptClearOptionsOptions and icons; the selection is ClearSelection's business, as in UMG.
UComboBoxStringClearSelectionadoptClearSelectionIndex -1, which is what this control already spells 'none'.
UComboBoxStringRefreshOptionsadoptRefreshOptionsFor a caller who edited the array in place.
UComboBoxStringSetSelectedOptionadoptSetSelectedOptionAn option nobody offers changes nothing, rather than clearing the selection.
UComboBoxStringSetSelectedIndexadoptSetSelectedIndex
UComboBoxStringGetSelectedOptionadoptGetSelectedOption
UComboBoxStringGetSelectedIndexadoptGetSelectedIndex
UComboBoxStringGetOptionCountadoptGetOptionCount
UComboBoxStringIsOpenadoptIsOpenMirrored from the behaviour's visibility seam, so a list closed by a click elsewhere is not still open here.
UComboBoxStringSetStyleadoptSetStyleNot a UFUNCTION on UComboBoxString (its Setter meta names it); added here so a look can be replaced at runtime.

本页目录