Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Managed pointers] Pointer state can be stuck when visual tree changes #17914

Open
Youssef1313 opened this issue Aug 12, 2024 · 3 comments
Open
Labels
area/skia ✏️ Categorizes an issue or PR as relevant to Skia difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform project/pointers 🖱️ Categorizes an issue or PR as relevant to mouse/touch/pen pointers triage/untriaged Indicates an issue requires triaging or verification

Comments

@Youssef1313
Copy link
Member

Current behavior

Use this XAML:

    <StackPanel x:Name="sp">
        <StackPanel.Resources>
            <ResourceDictionary>
                <Style x:Key="MyButtonStyle" TargetType="Button">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="Button">
                                <Grid x:Name="MyGrid" Width="50" Height="50">
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualState x:Name="Normal">
                                                <VisualState.Setters>
                                                    <Setter Target="MyGrid.Background" Value="Red" />
                                                </VisualState.Setters>
                                            </VisualState>
                                            <VisualState x:Name="Pressed">
                                                <VisualState.Setters>
                                                    <Setter Target="MyGrid.Background" Value="Green" />
                                                </VisualState.Setters>
                                            </VisualState>
                                            <VisualState x:Name="PointerOver">
                                                <VisualState.Setters>
                                                    <Setter Target="MyGrid.Background" Value="Yellow" />
                                                </VisualState.Setters>
                                            </VisualState>
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>

                    </Setter>
                </Style>
            </ResourceDictionary>
        </StackPanel.Resources>
        <Button Style="{StaticResource MyButtonStyle}" Click="Button_Click" x:Name="myBtn" />
    </StackPanel>

and code-behind:

        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new ContentDialog();
            dialog.XamlRoot = sp.XamlRoot;
            dialog.CloseButtonText = "Close";
            await dialog.ShowAsync();
        }

If you click the button, and don't move the mouse, you'll find that it's stuck in PointerOver state, while it should have been in Normal state. The root cause is that we are missing PointerExited event in this case.

Expected behavior

In WinUI, they have a special internal XCP_POINTERUPDATE event. They request it by calling RequestReplayPreviousPointerUpdate, and then this event will raise the relevant events, if needed.

How to reproduce it (as minimally and precisely as possible)

No response

Workaround

No response

Works on UWP/WinUI

None

Environment

No response

NuGet package version(s)

No response

Affected platforms

No response

IDE

No response

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

@Youssef1313 Youssef1313 added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. project/pointers 🖱️ Categorizes an issue or PR as relevant to mouse/touch/pen pointers labels Aug 12, 2024
@Youssef1313
Copy link
Member Author

The ContentDialog test change done in #17633 is caused by this issue. It may be best to revert the test change when this issue is resolved.

@dr1rrb
Copy link
Member

dr1rrb commented Aug 16, 2024

The ContentDialog test change done in #17633 is caused by this issue. It may be best to revert the test change when this issue is resolved.

Hummm for me it was only the focus of the button that has change, when the Dialog is being opened:
image
and then when we have tapped on the overlay:

image

@Youssef1313
Copy link
Member Author

Youssef1313 commented Aug 16, 2024

I think that's more the "hover" state, which happens because of the missing pointer exit event. The repro in the issue probably makes it more clear?

In the first screenshot, the button is in PointerOver visual state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/skia ✏️ Categorizes an issue or PR as relevant to Skia difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform project/pointers 🖱️ Categorizes an issue or PR as relevant to mouse/touch/pen pointers triage/untriaged Indicates an issue requires triaging or verification
Projects
None yet
Development

No branches or pull requests

2 participants