Page 1 of 1

Playing sound on GotFocus event - not ideal for gamepad controls

Posted: 30 Jun 2020, 08:26
by timday
Hi, new to the forum and hoping the problem I'm experiencing is just an oversight on my behalf.

At the moment, I am using the GotFocus triggered event on menu items to play a sound as the user navigates around, just like the Noesis samples.

This works fine when the user is using gamepad inputs to navigate the screen. But upon a screen first loading up we set the focus to the first element - and this of course triggers the sound. But as the user did not navigate to the element themselves this sound is out of place and undesirable.

The sample project demos either don't focus an element upon a screen loading (mouse input only, this does not work for gamepad input), or they tie the element focus with a visual animation to give the sound some context - I am specifically referring to the Menu3D sample in this case - but our menus have the focused element already highlighted on load so the sound is not tied to anything and shouldn't be played.

Any feedback greatly appreciated, thanks.

Re: Playing sound on GotFocus event - not ideal for gamepad controls

Posted: 03 Jul 2020, 14:27
by sfernandez
Assuming you are setting the focus when screen gets loaded, you can disable the sound action during that initial focus:
<i:Interaction.Triggers>
    <i:EventTrigger EventName="Loaded">
        <ei:ChangePropertyAction PropertyName="IsEnabled" Value="False" TargetName="FocusSound"/>
        <noesis:SetFocusAction/>
        <ei:ChangePropertyAction PropertyName="IsEnabled" Value="True" TargetName="FocusSound"/>
    </i:EventTrigger>
    <i:EventTrigger EventName="GotFocus">
        <ei:PlaySoundAction x:Name="FocusSound" Source="Focus.mp3"/>
    </i:EventTrigger>
</i:Interaction.Triggers>

Re: Playing sound on GotFocus event - not ideal for gamepad controls

Posted: 08 Jul 2020, 06:43
by timday
That's great, thanks!