ToolbarItemView VisualState Pressed/PointerOver/MouseOver

1 Answer 102 Views
Toolbar
Nico
Top achievements
Rank 1
Nico asked on 12 Sep 2023, 01:03 PM
I'm trying to set a VisualState style for Pressed/PointerOver/MouseOver etc. for the ToolbarItemView or ButtonToolbarItemView.
But somehow that doesn't seem to work. Definitely not Pressed for iOS and Android

Is there an example here, or could it be that this doesn't work?

<Setter Property="VisualStateManager.VisualStateGroups">
     <VisualStateGroupList>
         <VisualStateGroup x:Name="CommonStates">
             <VisualState x:Name="Normal" />
             <VisualState x:Name="Disabled">
                 <VisualState.Setters>
                     <Setter Property="Opacity" Value="0.5" />
                 </VisualState.Setters>
             </VisualState>
             <VisualState x:Name="Pressed">
                 <VisualState.Setters>
                     <Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource ButtonPointerOverColorLight}, Dark={StaticResource ButtonPointerOverColorDark}}" />
                     <Setter Property="BorderColor" Value="{AppThemeBinding Dark={StaticResource ButtonBorderColorDark}, Light={StaticResource ButtonBorderColorLight}}" />
                 </VisualState.Setters>
             </VisualState>
             <VisualState x:Name="PointerOver">
                 <VisualState.Setters>
                     <Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource ButtonPointerOverColorLight}, Dark={StaticResource ButtonPointerOverColorDark}}" />
                     <Setter Property="BorderColor" Value="{AppThemeBinding Dark={StaticResource ButtonBorderColorDark}, Light={StaticResource ButtonBorderColorLight}}" />
                 </VisualState.Setters>
             </VisualState>
             <VisualState x:Name="MouseOver">
                 <VisualState.Setters>
                     <Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource ButtonPointerOverColorLight}, Dark={StaticResource ButtonPointerOverColorDark}}" />
                     <Setter Property="BorderColor" Value="{AppThemeBinding Dark={StaticResource ButtonBorderColorDark}, Light={StaticResource ButtonBorderColorLight}}" />
                 </VisualState.Setters>
             </VisualState>
         </VisualStateGroup>
     </VisualStateGroupList>
</Setter>
Didi
Telerik team
commented on 14 Sep 2023, 03:34 PM

Hello Nico,

Thank you for the provided Toolbar definition.

I have reviewed the case and reproduced the behavior. On android the visual states do not apply. On WinUI the pressed state does not apply only point over. Point over applies as when you hover the toolbar item there is a style on point over. 

I have forwarded the case to the development team. They will review it and when more information is available, I or someone else from the team will get back to you with more details (next week). 

Regards,
Didi
Progress Telerik

A brand new .NET MAUI course was just added to the Virtual Classroom. The training course is developed to help you get started with the Telerik UI for .NET MAUI components and features. It aims to put you in the shoes of an engineer who adds new features to an existing application. You can check it out at https://learn.telerik.com

1 Answer, 1 is accepted

Sort by
0
Ivan
Telerik team
answered on 18 Sep 2023, 02:55 PM

Hello Nico,

According to the .NET MAUI documentation about visual states, there are the following pre-defined ones:

  • Normal
  • Disabled
  • Focused
  • Selected
  • PointerOver

There are no pre-defined visual states for MouseOver and Pressed.

Regarding the MouseOver state specifically, .NET MAUI has no notion of a "Mouse" in any shape or form. The mouse interaction is bolted in the framework via the pointer interactions. For this reason, to handle the MouseOver interaction, you should use the PointerOver visual state instead.

The same goes for the Pressed state. The framework supports user interaction via gesture recognizers. As you already know, there are build-in gesture recognizers for tap, pan, swipe etc., but there is nothing for low-level interactions such as pointer down/up: recognize a pointer gesture.

It is possible to emulate the missing functionality in the .NET MAUI framework on our side, by going down to native API level and implement it for each platform separately. We were hesitant to do this for the first version of the Toolbar for various technical reasons, as adding low-level touch interaction often prevents other gesture recognizers from working properly.

Anyway, the Pressed state seems like a viable feature to implement. I have created a feature request for it on your behalf: Add support for Pressed visual state on ButtonToolbarItemView. Please, do not forget to add your vote to raise its priority.

Regards,
Ivan
Progress Telerik

A brand new .NET MAUI course was just added to the Virtual Classroom. The training course is developed to help you get started with the Telerik UI for .NET MAUI components and features. It aims to put you in the shoes of an engineer who adds new features to an existing application. You can check it out at https://learn.telerik.com
Tags
Toolbar
Asked by
Nico
Top achievements
Rank 1
Answers by
Ivan
Telerik team
Share this question
or