UEnhancedInputLocalPlayerSubsystem::AddMappingContext
#include "EnhancedInputSubsystems.h"
Access: public
Specifiers: virtual
Description
Adds a UInputMappingContext to the active set for this player. Inputs mapped in the context begin firing immediately.
Signature
virtual void AddMappingContext(const UInputMappingContext* MappingContext, int32 Priority, const FModifyContextOptions& Options = FModifyContextOptions()) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| MappingContext | const UInputMappingContext* | The mapping context to activate. | — |
| Priority | int32 | Higher priority contexts override lower priority ones when keys conflict. | — |
| Options | const FModifyContextOptions& | Options for how the context change is applied (e.g. bIgnoreAllPressedKeysUntilRelease). | FModifyContextOptions() |
Return Type
void Caveats & Gotchas
- • Calling AddMappingContext with a context that is already active updates its priority. It does not add a duplicate.
- • Priority 0 is the lowest. Use higher values for contexts that should override others (e.g. UI context at priority 1 overrides gameplay context at priority 0).
- • FModifyContextOptions::bIgnoreAllPressedKeysUntilRelease prevents currently held keys from firing immediately when a new context is added — essential when switching to a UI context mid-gameplay.
Example
Switch between gameplay and UI contexts C++
// On menu open — add UI context at higher priority
FModifyContextOptions Options;
Options.bIgnoreAllPressedKeysUntilRelease = true;
Sub->AddMappingContext(UIContext, 1, Options);
// On menu close — remove UI context, gameplay resumes
Sub->RemoveMappingContext(UIContext); Tags
Version History
Introduced in: 5.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?