- JakeBungarrra
- Posts: 9
- Joined:
Gamepad_Accept not calling click events
Im trying to do a very basic click a button and run a function, the function works with the mouse and has no problem. but every time i try to use a gamepad it does not pick up the input, im not to sure what I am doing wrong.
I have a simple button
The button also has a style for triggers
This is the code that handles the click event and runs the function, within that function I get it run code (its a comment here, but I throw an exception every time to make sure it is working)
I also use the input mapper from the official documentation.
https://www.noesisengine.com/docs/2.2/G ... ml#gamepad
I would like to know if there is a reason behind this, or rather do I have to use certain event names, or certain triggers to get the A button on an Xbox controller calling the same as a mouse click.
I have a simple button
Which simple calls the click event.<Button x:Name="SPP_FreeSurfButton" Content="Button" Width="524" FontSize="72" Click="SPP_FreeSurfButton"/>
The button also has a style for triggers
Code: Select all
<Style x:Key="MainButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Background" Value="{StaticResource Menu.Button.Static.Background}"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" TargetName="border" Value="{StaticResource Menu.Button.MouseOver.Background}"/>
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Background" TargetName="border" Value="{StaticResource Menu.Button.Pressed.Background}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="border" Value="{StaticResource Menu.Button.Disabled.Background}"/>
</Trigger>
<Trigger Property="IsFocused" Value="true">
<Setter Property="Background" TargetName="border" Value="{StaticResource Menu.Button.MouseOver.Background}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Code: Select all
public partial class MenuMain : UserControl
{
//Headers---------------------------------------------------------
Viewbox root;
//----------------------------------------------------------------
public MenuMain()
{
InitializeComponent();
}
private void InitializeComponent()
{
Noesis.GUI.LoadComponent(this, "Assets/UI/MainMenu/MenuMain.xaml");
this.root = (Viewbox)FindName("MenuViewBox");
}
protected override bool ConnectEvent(object source, string eventName, string handlerName)
{
if (eventName == "Click" && handlerName == "SPP_FreeSurfButton")
{
((Button)source).Click += this.toFreeSurfPanel;
return true;
}
return false;
}
private void toFreeSurfPanel(object sender, RoutedEventArgs e)
{
//DO CLICK EVENT MAGIC
}
}
I also use the input mapper from the official documentation.
https://www.noesisengine.com/docs/2.2/G ... ml#gamepad
I would like to know if there is a reason behind this, or rather do I have to use certain event names, or certain triggers to get the A button on an Xbox controller calling the same as a mouse click.
- JakeBungarrra
- Posts: 9
- Joined:
Re: Gamepad_Accept not calling click events
The buttons work with a gamepad on the samples, but I have the same error of it not clicking the accept function, the buttons are getting called on the gamepad, just the click event is not.
I am using your input mapping system.
I am using your input mapping system.
-
sfernandez
Site Admin
- Posts: 2983
- Joined:
Re: Gamepad_Accept not calling click events
Is the MenuMain.ConnectEvent() function being called? That is the point where the Click event is connected to the callback function.
If ConnectEvent is not being called make sure that your xaml root has the correct x:Class attribute.
Also remark that Button must have keyboard focus in order to react to the Gamepad_Accept input.
If ConnectEvent is not being called make sure that your xaml root has the correct x:Class attribute.
Also remark that Button must have keyboard focus in order to react to the Gamepad_Accept input.
- JakeBungarrra
- Posts: 9
- Joined:
Re: Gamepad_Accept not calling click events
Code: Select all
protected override bool ConnectEvent(object source, string eventName, string handlerName)
{
if (eventName == "Click" && handlerName == "SPP_FreeSurfButton")
{
((Button)source).Click += this.toFreeSurfPanel;
return true;
}
return false;
}
The button is being called on the input as well, I simply use unity update function to do so.
Code: Select all
if (Input.GetButtonDown("Noesis_Accept"))
{
throw new System.Exception("Button Clicked");
}
what do you mean to have a keyboard focus? im assuming that when a button is focused on the button, is it what you mean by that?
X:class is correct and works.
-
sfernandez
Site Admin
- Posts: 2983
- Joined:
Re: Gamepad_Accept not calling click events
A workaround until next release is found here: #1524
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 75 guests