-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Conversation
oldRecognizers.CollectionChanged -= _collectionChangedHandler; | ||
|
||
if ((view as IGestureController)?.CompositeGestureRecognizers is ObservableCollection<IGestureRecognizer> oc) | ||
if (ElementGestureRecognizers is ObservableCollection<IGestureRecognizer> oc) |
There was a problem hiding this comment.
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)
There was a problem hiding this 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
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
src/Controls/src/Core/View.cs
Outdated
|
||
override protected internal void ChangeVisualState() | ||
{ | ||
if (IsPointerOver) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
src/Controls/src/Core/View.cs
Outdated
@@ -147,11 +150,33 @@ public IList<IGestureRecognizer> GestureRecognizers | |||
get { return _gestureRecognizers; } | |||
} | |||
|
|||
bool IsPointerOver = false; | |||
PointerGestureRecognizer _recognizerForPointerOverState = new PointerGestureRecognizer(); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
internal bool _isPointerOver = false; | |
internal bool IsPointerOver {get; private set;} |
e0000d3
to
3dc479a
Compare
Working well on windows and pretty well on mac! (mac has slightly inconsistent behavior that is reported here - #10227_ |
Description of Change
Introduces new visual state
PointerOver
for when the mouse cursor is hovering over a view.When both
PointerOver
andPressed
states are defined, thePointerOver
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