Extending GamepadTrigger::OnButtonPress to conditionally handle events
Posted: 10 Oct 2022, 22:09
Hello!
I'm currently attempting to extend the default GamepadTrigger behavior so that OnButtonPress will handle the associated event:
However, as noted in the code comment above, I'd like to only handle the event if the associated action was actually invoked in InvokeActions. InvokeActions performs a check to only actually call invoke on the associated actions if mPreviewInvoke does not set the PreviewInvokeEventArgs to 'cancelling = true'. For example, in the case where the GamepadTrigger has a ConditionalBehavior associated with it that is not satisfied in the given context, the call to InvokeActions would not actually perform the actions associated with the trigger.
However, InvokeActions does not return anything to indicate whether the associated actions were actually performed or not, so I'm not sure the best way to know in OnButtonPress whether the actions were performed - essentially, do you have any recommendations on replicating this code from InvokeActions within OnButtonPress/my GamepadTrigger class:
Any help would be appreciated!
I'm currently attempting to extend the default GamepadTrigger behavior so that OnButtonPress will handle the associated event:
Code: Select all
if (GetButton() == (GamepadButton)(e.originalKey - Noesis::Key_GamepadLeft))
{
InvokeActions(0);
// need logic here to only change e.handled if actions were actually invoked in InvokeActions
e.handled = true;
}However, InvokeActions does not return anything to indicate whether the associated actions were actually performed or not, so I'm not sure the best way to know in OnButtonPress whether the actions were performed - essentially, do you have any recommendations on replicating this code from InvokeActions within OnButtonPress/my GamepadTrigger class:
Code: Select all
PreviewInvokeEventArgs args; args.cancelling = false;
mPreviewInvoke(this, args);
if (!args.cancelling)
{}