problem with activating radio button when running not on launcher
i am trying to run the following code on SDL (it works on noesis launcher).
in noesis launcher the functionality works but on SDL not - i do not get any responce to press on the button.
i already run sucessfully some staff on sdl with event triggers etc but this is the first time i try to something like this with DataTriggers.
maybe i am missing some component registration?
thanks in advance
in noesis launcher the functionality works but on SDL not - i do not get any responce to press on the button.
Code: Select all
<UserControl x:Class="SelectOrientationScreen.cSelectOrientationView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SelectOrientationScreen"
xmlns:b="http://schemas.microsoft.com/expression/2010/interactivity">
<UserControl.Resources>
<Style x:Key="CustomRadioButtonStyle1" TargetType="RadioButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Canvas>
<Image x:Name="RadioButtonImage" />
<TextBlock x:Name="RadioButtonText" Text="{Binding RadioButton1Text}" Width="215" Height="64" FontWeight="Normal" FontSize="50" Margin="97,12,0,0"/>
</Canvas>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding IsChecked, RelativeSource={RelativeSource Self}}" Value="True">
<Setter TargetName="RadioButtonImage" Property="Source" Value="radio_button_on.png"/>
<Setter TargetName="RadioButtonText" Property="FontWeight" Value="Bold"/>
<Setter TargetName="RadioButtonText" Property="Foreground" Value="White"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsChecked, RelativeSource={RelativeSource Self}}" Value="False">
<Setter TargetName="RadioButtonImage" Property="Source" Value="radio_button_off.png"/>
<Setter TargetName="RadioButtonText" Property="FontWeight" Value="Normal"/>
<Setter TargetName="RadioButtonText" Property="Foreground" Value="#777AE0"/>
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Canvas>
<RadioButton x:Name="RadioButton1" IsChecked="{Binding IsRadioButton1On, Mode=TwoWay }" Style = "{StaticResource CustomRadioButtonStyle1}" Margin="152,420" Content="Checkbox 1"/>
</Canvas>
</UserControl>
maybe i am missing some component registration?
thanks in advance
Re: problem with activating radio button when running not on launcher
Does the log reveal any useful information? Does the radio button checks and unchecks when you click on it? (try with the style and without the style)
Re: problem with activating radio button when running not on launcher
nothing on the log.
i did another radio button without custom style but with interactions trigger and the test command i put works (i put a print debug to see command triggers).
i'd like to leave it working with style.
i have a wrapping function function for conversion of sdl events for example:
maybe i need also such code for data triggers?
it is just a guess should it work anyway?
thanks.
i did another radio button without custom style but with interactions trigger and the test command i put works (i put a print debug to see command triggers).
i'd like to leave it working with style.
i have a wrapping function function for conversion of sdl events for example:
Code: Select all
SDL_Event e;
while (SDL_PollEvent(&e) != 0) {
SDL_Window *eventWindow = SDL_GetWindowFromID(e.window.windowID);
if (eventWindow) {
SDL_GetWindowSize(eventWindow, &width, &height);
}
const auto active_view = getCurrentScreen()->screen_view;
switch (e.type) {
case SDL_QUIT:
quit = true;
break;
case SDL_WINDOWEVENT:
if (e.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
if (active_view) {
active_view->SetSize(width, height);
}
}
break;
case SDL_KEYDOWN:
case SDL_KEYUP: {
Noesis::Key key = ConvertSDLKeyCode(e.key.keysym.sym);
if (key != Noesis::Key_None) {
if (e.type == SDL_KEYDOWN) {
active_view->KeyDown(key);
} else {
active_view->KeyUp(key);
}
}
break;
}
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP: {
const Noesis::MouseButton button = ConvertSDLMouseButton(e.button.button);
const int x = e.button.x;
const int y = e.button.y;
if (e.type == SDL_MOUSEBUTTONDOWN) {
active_view->MouseButtonDown(x, y, button);
} else {
active_view->MouseButtonUp(x, y, button);
}
break;
}
case SDL_MOUSEMOTION: {
active_view->MouseMove(e.motion.x, e.motion.y);
break;
}
case SDL_MOUSEWHEEL: {
const int delta = e.wheel.y;
int x, y;
SDL_GetMouseState(&x, &y);
const float normX = static_cast<float>(x) / static_cast<float>(width);
const float normY = static_cast<float>(y) / static_cast<float>(height);
active_view->MouseWheel(normX, normY, delta);
break;
}
default:
break;
}
maybe i need also such code for data triggers?
it is just a guess should it work anyway?
thanks.
-
sfernandez
Site Admin
- Posts: 3093
- Joined:
Re: problem with activating radio button when running not on launcher
Hello,
First I would use in this case normal Triggers as you are not binding to a ViewModel property, it is better something like this:
And just to test if RadioButton is changing its IsChecked value when clicked, you can add a TextBlock binding to the IsChecked property.
First I would use in this case normal Triggers as you are not binding to a ViewModel property, it is better something like this:
Code: Select all
<UserControl x:Class="SelectOrientationScreen.cSelectOrientationView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SelectOrientationScreen"
xmlns:b="http://schemas.microsoft.com/expression/2010/interactivity">
<UserControl.Resources>
<Style x:Key="CustomRadioButtonStyle1" TargetType="RadioButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Canvas>
<Image x:Name="RadioButtonImage" Source="radio_button_off.png"/>
<TextBlock x:Name="RadioButtonText" Text="{Binding RadioButton1Text}" Foreground="#777AE0"
Width="215" Height="64" FontWeight="Normal" FontSize="50" Margin="97,12,0,0"/>
</Canvas>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="RadioButtonImage" Property="Source" Value="radio_button_on.png"/>
<Setter TargetName="RadioButtonText" Property="FontWeight" Value="Bold"/>
<Setter TargetName="RadioButtonText" Property="Foreground" Value="White"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Canvas>
<RadioButton x:Name="RadioButton1" IsChecked="{Binding IsRadioButton1On, Mode=TwoWay }"
Style="{StaticResource CustomRadioButtonStyle1}" Margin="152,420" Content="Checkbox 1"/>
<TextBlock Text="{Binding IsChecked, ElementName=RadioButton1}" IsHitTestVisible="False"/>
</Canvas>
</UserControl>
Re: problem with activating radio button when running not on launcher
thanks for the help.
solved issue
problem solved on the sdl i have a smal shift betwwen the place where the button shown and the actual place.
i increased button size.
thanks for help I've been debugging it for a few days.
solved issue
problem solved on the sdl i have a smal shift betwwen the place where the button shown and the actual place.
i increased button size.
thanks for help I've been debugging it for a few days.
Who is online
Users browsing this forum: No registered users and 4 guests