VisualState potentially off-by-one (or just wrong) on launch
I have this situation specifically with my child of the main view. There's a 50% chance on launch that we I `GoToStateAction` to `first_state` I actually go to that state or go to the state after it (say `second_state`). This is fixed by restarting Unreal without changing aynthing for me, I haven't tried what happens in the shipping build yet.
The code would look something like
The widgets[global_widget] is an implementation detail of how I'm communicating wtih NoesisGUI, but I wanted to include that in case binding to dict inside of a dict would have some relevance. BTW, this exact model works for virtually everything else, it's only the child of the main view that has this problem.
The code would look something like
Code: Select all
<Grid x:Name="RootGrid">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ui_mode_group">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0:0:0.1"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="normal"/>
<VisualState x:Name="none"/>
<VisualState x:Name="minigame">
<Storyboard>
...
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="combat_state_group">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="combat_inactive">
<Storyboard>
...
</Storyboard>
</VisualState>
<VisualState x:Name="combat_active">
<Storyboard>
...
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<b:Interaction.Triggers>
<b:PropertyChangedTrigger Binding="{Binding widgets[global_widget].strings[mode]}">
<b:GoToStateAction StateName="{Binding widgets[global_widget].strings[mode]}" />
</b:PropertyChangedTrigger>
<b:PropertyChangedTrigger Binding="{Binding widgets[global_widget].strings[combat_state]}">
<b:GoToStateAction StateName="{Binding widgets[global_widget].strings[combat_state]}" />
</b:PropertyChangedTrigger>
</b:Interaction.Triggers>
-
sfernandez
Site Admin
- Posts: 3109
- Joined:
Re: VisualState potentially off-by-one (or just wrong) on launch
You mean that GoToStateAction is invoked with the wrong StateName?
Is it possible that in those cases the name of the state is the previous value of the bound property?
Because I'm thinking that maybe the PropertyChangedTrigger is executed before the binding in the GoToStateAction is reevaluated. If that is the case the solution would be to ensure the value of the StateName property is updated when the action is invoked:
Is it possible that in those cases the name of the state is the previous value of the bound property?
Because I'm thinking that maybe the PropertyChangedTrigger is executed before the binding in the GoToStateAction is reevaluated. If that is the case the solution would be to ensure the value of the StateName property is updated when the action is invoked:
Code: Select all
void GoToStateAction::Invoke(BaseComponent*)
{
if (GetAssociatedObject() != 0 && mStateTarget != 0)
{
DataBindingHelper::EnsureBindingValue(this, StateNameProperty);
const char* stateName = GetStateName();
...
}
}
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 8 guests