DreamGUI
类参考

UDreamInputKeySelector

A button whose label is a bound key, and which listens for the next one when clicked.

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

Inherits from UDreamUIControl.

Declared in Public/Controls/DreamInputKeySelector.h.

A button whose label is a bound key, and which listens for the next one when clicked.

Two nodes and one behaviour, the button's anatomy exactly -- the face IS the root, with the key's name centred on it -- because that is what this control is: a button carrying a value. Clicking it ARMS it (bIsListening), the next key it is told about becomes the value, and it disarms.

WHERE THE KEY COMES FROM, plainly, because this plugin has no hook that would supply it and this class does not pretend otherwise. What exists here is:

  • UDreamUIActionRouter, which routes NAMED actions from a data table. It resolves a key to an action and fires that action's callback; it cannot report the key itself, and a rebinder needs the key, not the meaning.
  • ADreamStandaloneInputEventSystemActor, which does hold real FKeys -- its AnyKey binding is where they arrive -- but forwards them straight into navigation and the router and broadcasts nothing. OnAnyKeyPressed is private and not virtual.
  • UDreamUserWidget's Blueprint surface, which is pointer, drag, focus and navigation. No keys. (UUITextInput does capture raw keys, by spawning an actor with AutoReceiveInput and binding every key on it. That is a text field's bargain -- one actor per active field, consuming what it binds -- and inventing a second copy of it inside a control is not something this class does quietly.)

So the arming, the state, the visual and the value live here, and the KEY IS FED IN: while this is listening, the project's input layer calls NotifyKeyPressed with whatever the player pressed, and it returns true when it took it. That layer is wherever the project already sees keys -- its PlayerController, an Enhanced Input action, or a subclass of ADreamStandaloneInputEventSystemActor overriding BindActionRouting (which is virtual for exactly this kind of extension). SetSelectedKey writes the value with no listening involved, for a settings screen restoring saved bindings.

UMG parity is UInputKeySelector's core: SelectedChord (with SelectedKey as its bare-key spelling), bIsListening, OnKeySelected, OnIsSelectingKey -- plus the library's OnValueChangedBP, because the key is a value and <-> binds against it.

/Script/DreamGUIControls.DreamInputKeySelector JumpBinding {
    SelectedKey = (KeyName="SpaceBar")
    OnKeySelected -> HandleJumpRebound

Properties

NameTypeCategoryIn the details panelFrom BlueprintDescription
StyleFDreamInputKeySelectorStyleInput Key SelectoryesGetStyle / 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.
SelectedChordFInputChordInput Key SelectoryesGetSelectedChord / SetSelectedChordThe bound key WITH its modifiers -- UMG's FInputChord, and the control's real value.
SelectedKeyFKeyInput Key SelectoryesGetSelectedKey / SetSelectedKeyThe compatibility spelling: the chord's KEY alone, with its modifiers dropped. Kept as a property because existing .dui authors it (SelectedKey = (KeyName="SpaceBar")) and binds against it, and because <-> resolves a property; kept coherent with SelectedChord through every path. Where the two are authored to disagree see ReconcileKeySpellings.
NoKeyTextFTextInput Key SelectoryesGetNoKeyText / SetNoKeyTextShown while nothing is bound. Empty keeps the built-in words, as an empty brush keeps a glyph.
ListeningTextFTextInput Key SelectoryesGetListeningText / SetListeningTextShown while armed. Empty keeps the built-in words.
bEscapeCancelsboolInput Key SelectoryesGetEscapeCancels / SetEscapeCancelsEscape disarms instead of binding. On by default and for the reason UMG reserves its escape keys: a player who opened this by accident needs one key that is guaranteed to be a way out, and a control that will bind ANY key does not have one.
EscapeKeysTArray<FKey>Input Key SelectoryesGetEscapeKeys / SetEscapeKeysWHICH keys are the way out -- UMG's EscapeKeys, a list rather than the one hard-coded Escape this control used to reserve.
bAllowModifierKeysboolInput Key SelectoryesAllowModifierKeys / SetAllowModifierKeysWhether a captured key takes the modifiers held with it.
bAllowGamepadKeysboolInput Key SelectoryesAllowGamepadKeys / SetAllowGamepadKeysWhether a PAD key can become the binding -- UMG's bAllowGamepadKeys.
FaceNodeTObjectPtr<UDreamWidget>Input Key Selector-read only
LabelNodeTObjectPtr<UDreamWidget>Input Key Selector-read only
ButtonBehaviourTObjectPtr<UUIButton>Input Key Selector-read only
bIsListeningboolInput Key Selector-read onlyWhether it is armed. Transient and read-only, never authored: arming is something the player did a moment ago, and a .dui that could author it would author a control that eats the next key of whatever screen it is on. SetIsListening is the only writer.
bCaptureKeysWhileListeningboolInput Key SelectoryesGetCaptureKeysWhileListening / SetCaptureKeysWhileListeningWhether arming also listens for the key itself.

Functions

FunctionKindDescription
bool AllowGamepadKeys()pureAllow Gamepad Keys
bool AllowModifierKeys()pureUMG's spelling of GetAllowModifierKeys, which is the name its own getter carries.
void BeginListening()callableArm it: the next key fed to NotifyKeyPressed is the new binding. What a click does.
void CancelListening()callableDisarm without binding anything. What Escape does, and what a closing screen should do.
bool GetCaptureKeysWhileListening()pureGet Capture Keys While Listening
bool GetEscapeCancels()pureGet Escape Cancels
TArray<FKey> GetEscapeKeys()pureGet Escape Keys
bool GetIsListening()pureGet Is Listening
bool GetIsSelectingKey()pureUMG's GetIsSelectingKey: the armed state under the name UMG gives it.
FText GetListeningText()pureGet Listening Text
FText GetNoKeyText()pureGet No Key Text
FInputChord GetSelectedChord()pureGet Selected Chord
FKey GetSelectedKey()pureGet Selected Key
FDreamInputKeySelectorStyle GetStyle()pureGet Style
bool NotifyChordPressed(FInputChord InChord)callableThe chord-shaped twin, for a project whose input layer knows which modifiers were down. NotifyKeyPressed is exactly this with no modifiers, so the two cannot come to mean different things: it forwards here.
bool NotifyKeyPressed(FKey InKey)callableOffer a key to this selector. THE ENTRY POINT the class comment is about: nothing in this plugin calls it, the project's own input layer does.
void SetAllowGamepadKeys(bool bInAllowGamepadKeys)callableSet Allow Gamepad Keys
void SetAllowModifierKeys(bool bInAllowModifierKeys)callableSet Allow Modifier Keys
void SetCaptureKeysWhileListening(bool bInCaptureKeysWhileListening)callableTurning it off while armed releases the agent at once; a capture nobody can stop is a trap.
void SetEscapeCancels(bool bInEscapeCancels)callableSet Escape Cancels
void SetEscapeKeys(TArray<FKey> InKeys)callableWhich keys are the way out. An empty list means there is none -- see the property.
void SetKeySelectionText(FText InKeySelectionText)callableUMG's name for the prompt shown while armed.
void SetListeningText(FText InListeningText)callableSet Listening Text
void SetNoKeySpecifiedText(FText InNoKeySpecifiedText)callableUMG's name for the same words. One field, two spellings.
void SetNoKeyText(FText InNoKeyText)callableRe-labels at once when nothing is bound, which is the only state that shows these words.
void SetSelectedChord(FInputChord InChord)callableThe whole binding, modifiers included. The one writer both spellings go through.
void SetSelectedKey(FKey InKey)callableWrites the value and re-labels; broadcasts only when the binding actually moves. Never listens.
void SetStyle(FDreamInputKeySelectorStyle InStyle)callableThe whole look at once, re-pushed -- including the face colours, which follow the armed state.
void SetTextBlockVisibility(EDreamWidgetVisibility InVisibility)callableShow or hide the words on the face -- UMG's SetTextBlockVisibility.

Events

EventSignatureDescription
OnKeySelectedvoid DreamInputKeySelectorKeyEvent__DelegateSignature(FKey SelectedKey)Fired when a key is bound, from a listen or from SetSelectedKey. Carries the chord's KEY.
OnChordSelectedvoid DreamInputKeySelectorChordEvent__DelegateSignature(FInputChord SelectedChord)The same moment, carrying the whole chord. Fires alongside OnKeySelected.
OnIsListeningChangedvoid DreamInputKeySelectorListeningEvent__DelegateSignature(bool bIsListening)Fired when the armed state moves, so a screen can dim the rest of itself while one is armed.
OnValueChangedBPvoid DreamInputKeySelectorKeyEvent__DelegateSignature(FKey SelectedKey)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.

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
UInputKeySelectorWidgetStylemapStyleFDreamInputKeySelectorStyle: the button's five state colours plus the sixth this control needs -- Listening, which is the whole of the 'press a key now' feedback.
UInputKeySelectorTextStylemapStyleThe label's colour and size are FDreamInputKeySelectorStyle::LabelColor and FontSize; this library does not split a control's look into a button style and a text style.
UInputKeySelectorSelectedKeymapSelectedChordUMG's SelectedKey IS an FInputChord, so the chord is the faithful mapping. This control also carries a bare-FKey SelectedKey as the compatibility spelling existing .dui authors, kept coherent through every writer.
UInputKeySelectorMarginmapFDreamInputKeySelectorStyle::ContentPaddingSpace around the key's name. Appearance, so it lives in the style struct.
UInputKeySelectorKeySelectionTextmapListeningTextSetKeySelectionText carries the UMG name and forwards. Empty keeps the built-in words, so a project overrides the prompt without overriding the control.
UInputKeySelectorNoKeySpecifiedTextmapNoKeyTextSetNoKeySpecifiedText carries the UMG name and forwards.
UInputKeySelectorbAllowModifierKeysadoptbAllowModifierKeysOnly the CAPTURE path reads it: NotifyKeyPressed and NotifyChordPressed are fed by a caller that already knows what was held.
UInputKeySelectorbAllowGamepadKeysadoptbAllowGamepadKeysOn by default, which is what the capture agent already did. Off, a pad key is neither bound nor CONSUMED -- it was meant for something else, and swallowing it would leave a controller doing nothing while a selector is armed. The escape keys are checked first, so the pad's B is still a way out.
UInputKeySelectorEscapeKeysadoptEscapeKeysSeeded with Escape and the pad's B. Emptying it is legal and means the click is the only way out, which the header documents as a trap.
UInputKeySelectorOnKeySelectedmapOnChordSelectedUMG's carries an FInputChord, which is OnChordSelected here. This control also fires OnKeySelected with the bare key from the same moment, for a consumer that only cares which key.
UInputKeySelectorOnIsSelectingKeyChangedmapOnIsListeningChangedCarries the new state, where UMG's carries nothing -- a handler that dims the rest of the screen needs to know which way it went.
UInputKeySelectorSetSelectedKeymapSetSelectedChordUMG's takes an FInputChord. SetSelectedKey exists here too and takes a bare FKey, which CLEARS any modifiers: 'bind exactly this key' is what a caller of the key-shaped setter is saying.
UInputKeySelectorSetKeySelectionTextadoptSetKeySelectionTextForwards to SetListeningText, which re-labels at once.
UInputKeySelectorSetNoKeySpecifiedTextadoptSetNoKeySpecifiedTextForwards to SetNoKeyText.
UInputKeySelectorSetAllowModifierKeysadoptSetAllowModifierKeys
UInputKeySelectorSetAllowGamepadKeysadoptSetAllowGamepadKeys
UInputKeySelectorGetIsSelectingKeyadoptGetIsSelectingKeyThe armed state under UMG's name; GetIsListening is the library's own spelling of the same flag.
UInputKeySelectorSetTextBlockVisibilityadoptSetTextBlockVisibilityTakes EDreamWidgetVisibility, this library's own five answers for the same question. The LABEL only: the face keeps its visibility, so the selector stays clickable, which is the documented way out of the armed state.
UInputKeySelectorSetEscapeKeysadoptSetEscapeKeys

本页目录