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 -> HandleJumpReboundProperties
| Name | Type | Category | In the details panel | From Blueprint | Description |
|---|---|---|---|---|---|
Style | FDreamInputKeySelectorStyle | Input Key Selector | yes | GetStyle / SetStyle | This 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. |
SelectedChord | FInputChord | Input Key Selector | yes | GetSelectedChord / SetSelectedChord | The bound key WITH its modifiers -- UMG's FInputChord, and the control's real value. |
SelectedKey | FKey | Input Key Selector | yes | GetSelectedKey / SetSelectedKey | The 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. |
NoKeyText | FText | Input Key Selector | yes | GetNoKeyText / SetNoKeyText | Shown while nothing is bound. Empty keeps the built-in words, as an empty brush keeps a glyph. |
ListeningText | FText | Input Key Selector | yes | GetListeningText / SetListeningText | Shown while armed. Empty keeps the built-in words. |
bEscapeCancels | bool | Input Key Selector | yes | GetEscapeCancels / SetEscapeCancels | Escape 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. |
EscapeKeys | TArray<FKey> | Input Key Selector | yes | GetEscapeKeys / SetEscapeKeys | WHICH keys are the way out -- UMG's EscapeKeys, a list rather than the one hard-coded Escape this control used to reserve. |
bAllowModifierKeys | bool | Input Key Selector | yes | AllowModifierKeys / SetAllowModifierKeys | Whether a captured key takes the modifiers held with it. |
bAllowGamepadKeys | bool | Input Key Selector | yes | AllowGamepadKeys / SetAllowGamepadKeys | Whether a PAD key can become the binding -- UMG's bAllowGamepadKeys. |
FaceNode | TObjectPtr<UDreamWidget> | Input Key Selector | - | read only | |
LabelNode | TObjectPtr<UDreamWidget> | Input Key Selector | - | read only | |
ButtonBehaviour | TObjectPtr<UUIButton> | Input Key Selector | - | read only | |
bIsListening | bool | Input Key Selector | - | read only | Whether 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. |
bCaptureKeysWhileListening | bool | Input Key Selector | yes | GetCaptureKeysWhileListening / SetCaptureKeysWhileListening | Whether arming also listens for the key itself. |
Functions
| Function | Kind | Description |
|---|---|---|
bool AllowGamepadKeys() | pure | Allow Gamepad Keys |
bool AllowModifierKeys() | pure | UMG's spelling of GetAllowModifierKeys, which is the name its own getter carries. |
void BeginListening() | callable | Arm it: the next key fed to NotifyKeyPressed is the new binding. What a click does. |
void CancelListening() | callable | Disarm without binding anything. What Escape does, and what a closing screen should do. |
bool GetCaptureKeysWhileListening() | pure | Get Capture Keys While Listening |
bool GetEscapeCancels() | pure | Get Escape Cancels |
TArray<FKey> GetEscapeKeys() | pure | Get Escape Keys |
bool GetIsListening() | pure | Get Is Listening |
bool GetIsSelectingKey() | pure | UMG's GetIsSelectingKey: the armed state under the name UMG gives it. |
FText GetListeningText() | pure | Get Listening Text |
FText GetNoKeyText() | pure | Get No Key Text |
FInputChord GetSelectedChord() | pure | Get Selected Chord |
FKey GetSelectedKey() | pure | Get Selected Key |
FDreamInputKeySelectorStyle GetStyle() | pure | Get Style |
bool NotifyChordPressed(FInputChord InChord) | callable | The 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) | callable | Offer 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) | callable | Set Allow Gamepad Keys |
void SetAllowModifierKeys(bool bInAllowModifierKeys) | callable | Set Allow Modifier Keys |
void SetCaptureKeysWhileListening(bool bInCaptureKeysWhileListening) | callable | Turning it off while armed releases the agent at once; a capture nobody can stop is a trap. |
void SetEscapeCancels(bool bInEscapeCancels) | callable | Set Escape Cancels |
void SetEscapeKeys(TArray<FKey> InKeys) | callable | Which keys are the way out. An empty list means there is none -- see the property. |
void SetKeySelectionText(FText InKeySelectionText) | callable | UMG's name for the prompt shown while armed. |
void SetListeningText(FText InListeningText) | callable | Set Listening Text |
void SetNoKeySpecifiedText(FText InNoKeySpecifiedText) | callable | UMG's name for the same words. One field, two spellings. |
void SetNoKeyText(FText InNoKeyText) | callable | Re-labels at once when nothing is bound, which is the only state that shows these words. |
void SetSelectedChord(FInputChord InChord) | callable | The whole binding, modifiers included. The one writer both spellings go through. |
void SetSelectedKey(FKey InKey) | callable | Writes the value and re-labels; broadcasts only when the binding actually moves. Never listens. |
void SetStyle(FDreamInputKeySelectorStyle InStyle) | callable | The whole look at once, re-pushed -- including the face colours, which follow the armed state. |
void SetTextBlockVisibility(EDreamWidgetVisibility InVisibility) | callable | Show or hide the words on the face -- UMG's SetTextBlockVisibility. |
Events
| Event | Signature | Description |
|---|---|---|
OnKeySelected | void DreamInputKeySelectorKeyEvent__DelegateSignature(FKey SelectedKey) | Fired when a key is bound, from a listen or from SetSelectedKey. Carries the chord's KEY. |
OnChordSelected | void DreamInputKeySelectorChordEvent__DelegateSignature(FInputChord SelectedChord) | The same moment, carrying the whole chord. Fires alongside OnKeySelected. |
OnIsListeningChanged | void DreamInputKeySelectorListeningEvent__DelegateSignature(bool bIsListening) | Fired when the armed state moves, so a screen can dim the rest of itself while one is armed. |
OnValueChangedBP | void 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.
| UMG | Member | Status | Here | Note |
|---|---|---|---|---|
UInputKeySelector | WidgetStyle | map | Style | FDreamInputKeySelectorStyle: the button's five state colours plus the sixth this control needs -- Listening, which is the whole of the 'press a key now' feedback. |
UInputKeySelector | TextStyle | map | Style | The 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. |
UInputKeySelector | SelectedKey | map | SelectedChord | UMG'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. |
UInputKeySelector | Margin | map | FDreamInputKeySelectorStyle::ContentPadding | Space around the key's name. Appearance, so it lives in the style struct. |
UInputKeySelector | KeySelectionText | map | ListeningText | SetKeySelectionText carries the UMG name and forwards. Empty keeps the built-in words, so a project overrides the prompt without overriding the control. |
UInputKeySelector | NoKeySpecifiedText | map | NoKeyText | SetNoKeySpecifiedText carries the UMG name and forwards. |
UInputKeySelector | bAllowModifierKeys | adopt | bAllowModifierKeys | Only the CAPTURE path reads it: NotifyKeyPressed and NotifyChordPressed are fed by a caller that already knows what was held. |
UInputKeySelector | bAllowGamepadKeys | adopt | bAllowGamepadKeys | On 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. |
UInputKeySelector | EscapeKeys | adopt | EscapeKeys | Seeded 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. |
UInputKeySelector | OnKeySelected | map | OnChordSelected | UMG'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. |
UInputKeySelector | OnIsSelectingKeyChanged | map | OnIsListeningChanged | Carries the new state, where UMG's carries nothing -- a handler that dims the rest of the screen needs to know which way it went. |
UInputKeySelector | SetSelectedKey | map | SetSelectedChord | UMG'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. |
UInputKeySelector | SetKeySelectionText | adopt | SetKeySelectionText | Forwards to SetListeningText, which re-labels at once. |
UInputKeySelector | SetNoKeySpecifiedText | adopt | SetNoKeySpecifiedText | Forwards to SetNoKeyText. |
UInputKeySelector | SetAllowModifierKeys | adopt | SetAllowModifierKeys | |
UInputKeySelector | SetAllowGamepadKeys | adopt | SetAllowGamepadKeys | |
UInputKeySelector | GetIsSelectingKey | adopt | GetIsSelectingKey | The armed state under UMG's name; GetIsListening is the library's own spelling of the same flag. |
UInputKeySelector | SetTextBlockVisibility | adopt | SetTextBlockVisibility | Takes 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. |
UInputKeySelector | SetEscapeKeys | adopt | SetEscapeKeys |