Skip to content

Commit

Permalink
More updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rachelkang committed Sep 20, 2022
1 parent 4d43024 commit 3dc479a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,39 @@
Text=""
Placeholder="Type something to enable 2nd Entry" />
<Label
Text="Label with Normal, PointerOver, and Pressed visual states:"
Text="Button with Normal and PointerOver visual states:"
Style="{StaticResource Headline}" />
<Button
Text="Login"
Text="Hover me to see color change"
WidthRequest="300"
HorizontalOptions="Center">
<VisualStateManager.VisualStateGroups>
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="LightBlue" />
<Setter Property="BorderColor" Value="LightBlue" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="PointerOver">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="Blue" />
<Setter Property="BorderColor" Value="LightBlue" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</VisualStateManager.VisualStateGroups>
</Button>
<Label
Text="Button with Normal, PointerOver, and Pressed visual states:"
Style="{StaticResource Headline}" />
<Label
Text="The Normal and PointerOver states for this button are the same. This demonstrates how the PointerOver state can be used to set the visual state of the button after it has been clicked so that it's no longer Pressed."
FontSize="Body"/>
<Button
Text="Click me to see color change and revert back"
WidthRequest="300"
HorizontalOptions="Center">
<VisualStateManager.VisualStateGroups>
Expand Down Expand Up @@ -99,7 +128,6 @@
</VisualStateGroupList>
</VisualStateManager.VisualStateGroups>
</Button>

</StackLayout>
</views:BasePage.Content>
</views:BasePage>
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ static Microsoft.Maui.Controls.Toolbar.MapTitle(Microsoft.Maui.Handlers.IToolbar
static Microsoft.Maui.Controls.Toolbar.MapTitleIcon(Microsoft.Maui.Handlers.IToolbarHandler! arg1, Microsoft.Maui.Controls.Toolbar! arg2) -> void
static Microsoft.Maui.Controls.Toolbar.MapTitleView(Microsoft.Maui.Handlers.IToolbarHandler! arg1, Microsoft.Maui.Controls.Toolbar! arg2) -> void
static Microsoft.Maui.Controls.Toolbar.MapToolbarItems(Microsoft.Maui.Handlers.IToolbarHandler! arg1, Microsoft.Maui.Controls.Toolbar! arg2) -> void
override Microsoft.Maui.Controls.View.ChangeVisualState() -> void
static Microsoft.Maui.Controls.ToolTipProperties.GetText(Microsoft.Maui.Controls.BindableObject! bindable) -> object!
static Microsoft.Maui.Controls.ToolTipProperties.SetText(Microsoft.Maui.Controls.BindableObject! bindable, object! value) -> void
static Microsoft.Maui.Controls.Window.MapContent(Microsoft.Maui.Handlers.IWindowHandler! handler, Microsoft.Maui.IWindow! view) -> void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ static Microsoft.Maui.Controls.Toolbar.MapBackButtonEnabled(Microsoft.Maui.Handl
static Microsoft.Maui.Controls.Toolbar.MapIcon(Microsoft.Maui.Handlers.IToolbarHandler! arg1, Microsoft.Maui.Controls.Toolbar! arg2) -> void
static Microsoft.Maui.Controls.Toolbar.MapToolbarDynamicOverflowEnabled(Microsoft.Maui.Handlers.IToolbarHandler! arg1, Microsoft.Maui.Controls.Toolbar! arg2) -> void
static Microsoft.Maui.Controls.Toolbar.MapToolbarPlacement(Microsoft.Maui.Handlers.IToolbarHandler! arg1, Microsoft.Maui.Controls.Toolbar! arg2) -> void
override Microsoft.Maui.Controls.View.ChangeVisualState() -> void
static readonly Microsoft.Maui.Controls.PointerGestureRecognizer.PointerEnteredCommandParameterProperty -> Microsoft.Maui.Controls.BindableProperty!
static readonly Microsoft.Maui.Controls.PointerGestureRecognizer.PointerEnteredCommandProperty -> Microsoft.Maui.Controls.BindableProperty!
static readonly Microsoft.Maui.Controls.PointerGestureRecognizer.PointerExitedCommandParameterProperty -> Microsoft.Maui.Controls.BindableProperty!
Expand Down
2 changes: 0 additions & 2 deletions src/Controls/src/Core/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,11 @@ IList<IGestureRecognizer> IGestureController.CompositeGestureRecognizers
_recognizerForPointerOverState.PointerEntered += (s, e) =>
{
IsPointerOver = true;
ChangeVisualState();
};

_recognizerForPointerOverState.PointerExited += (s, e) =>
{
IsPointerOver = false;
ChangeVisualState();
};

_compositeGestureRecognizers = new ObservableCollection<IGestureRecognizer>() { _recognizerForPointerOverState };
Expand Down
15 changes: 14 additions & 1 deletion src/Controls/src/Core/VisualElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,20 @@ void PropagateBindingContextToStateTriggers()

internal void ChangeVisualStateInternal() => ChangeVisualState();

internal bool IsPointerOver { get; private protected set; }
bool _isPointerOver;

internal bool IsPointerOver
{
get { return _isPointerOver; }
private protected set
{
if (value == _isPointerOver)
return;

_isPointerOver = value;
ChangeVisualState();
}
}

protected internal virtual void ChangeVisualState()
{
Expand Down

0 comments on commit 3dc479a

Please sign in to comment.