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

Add visual state for PointerOver #10003

Merged
merged 17 commits into from
Sep 20, 2022
Merged

Add visual state for PointerOver #10003

merged 17 commits into from
Sep 20, 2022

Conversation

rachelkang
Copy link
Member

@rachelkang rachelkang commented Sep 8, 2022

Description of Change

Introduces new visual state PointerOver for when the mouse cursor is hovering over a view.
When both PointerOver and Pressed states are defined, the PointerOver state kicks in when the view is still hovered but not pressed.

Related to #9592
Related to #9861

Issues Fixed

Provides workaround for #7570
Provides workaround for #9715

Related to #9139

oldRecognizers.CollectionChanged -= _collectionChangedHandler;

if ((view as IGestureController)?.CompositeGestureRecognizers is ObservableCollection<IGestureRecognizer> oc)
if (ElementGestureRecognizers is ObservableCollection<IGestureRecognizer> oc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these can just be

if (ElementGestureRecognizers != null)

Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you'll need to add logic so that calling

Element.GestureRecognizers.Clear()

Doesn't remove your PointerGestureRecognizer from the composite controls

image

Maybe add some tests here

Where you can validate that the PointerGestureRecognizer gets added to the composite collection and that it stays around after calling clear

@jsuarezruiz jsuarezruiz added the area-xaml XAML, CSS, Triggers, Behaviors label Sep 9, 2022
@Redth Redth added this to the 7.0-rc2 milestone Sep 14, 2022
@rachelkang rachelkang changed the title Add visual state for PointerEntered Add visual state for PointerOver Sep 14, 2022

override protected internal void ChangeVisualState()
{
if (IsPointerOver)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say just move this to VisualElement where the other checks are and that Disabled should take precedence over IsPointerOver

That's how the ordering works for WinUI so we should just stay consistent


#if !ANDROID
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests don't run on a device they just run as a netstandard library so the ANDROID definition areas will have no effect.

@@ -147,11 +150,33 @@ public IList<IGestureRecognizer> GestureRecognizers
get { return _gestureRecognizers; }
}

bool IsPointerOver = false;
PointerGestureRecognizer _recognizerForPointerOverState = new PointerGestureRecognizer();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Move these properties to the top of the file
  • I wouldn't instantiate this here. Instantiate it inside CompositeGesturesRecognizers

_recognizerForPointerOverState ??= new PointerGestureRecognizer();

@@ -1087,10 +1087,14 @@ void PropagateBindingContextToStateTriggers()

internal void ChangeVisualStateInternal() => ChangeVisualState();

protected internal bool IsPointerOver = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove protected

@@ -1087,10 +1087,14 @@ void PropagateBindingContextToStateTriggers()

internal void ChangeVisualStateInternal() => ChangeVisualState();

internal bool _isPointerOver = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
internal bool _isPointerOver = false;
internal bool IsPointerOver {get; private set;}

@rachelkang
Copy link
Member Author

Working well on windows and pretty well on mac!

(mac has slightly inconsistent behavior that is reported here - #10227_

@PureWeen PureWeen enabled auto-merge (squash) September 20, 2022 20:07
@PureWeen PureWeen merged commit 4432b3d into main Sep 20, 2022
@PureWeen PureWeen deleted the pointer_gesture_vsm branch September 20, 2022 21:04
@github-actions github-actions bot locked and limited conversation to collaborators Dec 18, 2023
@samhouts samhouts added the fixed-in-7.0.0-rc.2.6866 Look for this fix in 7.0.0-rc.2.6866! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-xaml XAML, CSS, Triggers, Behaviors fixed-in-7.0.0-rc.2.6866 Look for this fix in 7.0.0-rc.2.6866!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants