ViaCognita
(ViaCognita)
February 26, 2024, 11:55am
1
Hi!
I’m using Unreal 5.3.2.
If I did:
EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &ARSPlayerController::MoveActionMethod);
and I want to remove this binding.
What do I have to do?
Do I have to use RemoveBindingByHandle
? But which is the Handle
parameter?
Thanks!
IrSoil
(IrSoil)
February 26, 2024, 12:35pm
2
BindAction
does return the handle you need, so just store it instead of discarding
ViaCognita
(ViaCognita)
February 26, 2024, 1:59pm
3
BindAction
has this signature:
template<class UserClass>
FEnhancedInputActionEventBinding & BindAction
(
const UInputAction * Action,
ETriggerEvent TriggerEvent,
UserClass * Object,
typename FEnhancedInputActionHandlerSignature::TUObjectMethodDelegate< UserClass >::FMethodPtr Func
)
FEnhancedInputActionEventBinding
is:
struct FEnhancedInputActionEventBinding : public FInputBindingHandle
And FInputBindingHandle has the following method:
uint32 GetHandle() const
What do you mean with “BindAction
does return the handle you need ”?
And also, what do I have to store it instead of discarding ?
Thanks!
IrSoil
(IrSoil)
February 26, 2024, 2:46pm
4
While my answer indeed was a bit incomplete, you pretty much found the solution correctly: FEnhancedInputActionEventBinding::GetHandle()
will return the handle you should pass to EnhancedInputComponent::RemoveBindingByHandle()
.
So, as an example of all of this smashed together:
//header
TArray<uint32> Handles;
//cpp
{
auto EnhancedIC = Cast<UEnhancedInputComponent>(InputComponent);
//...
const auto& Binding = EnhancedIC->BindAction(Input.Action, ETriggerEvent::Triggered, this, &AMyController::MyAction);
Handles.Add(Binding.GetHandle());
// ... somewhere later ...
for (auto Handle : Handles)
{
EnhancedIC->RemoveBindingByHandle(Handle);
}
}
2 Likes
system
(system)
Closed
March 27, 2024, 2:46pm
5
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.