diff --git a/Demo/App.iOS/App.iOS.csproj b/Demo/App.iOS/App.iOS.csproj
index d9b795f..70000aa 100644
--- a/Demo/App.iOS/App.iOS.csproj
+++ b/Demo/App.iOS/App.iOS.csproj
@@ -36,6 +36,8 @@
4
None
x86_64
+ Apple Development: Ieuan Walker (R4SVVV33HW)
+ VS: WildCard Development
true
diff --git a/Demo/App/App.csproj b/Demo/App/App.csproj
index 23f721d..16f3c10 100644
--- a/Demo/App/App.csproj
+++ b/Demo/App/App.csproj
@@ -19,4 +19,10 @@
+
+
+
+ MSBuild:UpdateDesignTimeXaml
+
+
\ No newline at end of file
diff --git a/Demo/App/App.xaml.cs b/Demo/App/App.xaml.cs
index a48e404..a5f9d9d 100644
--- a/Demo/App/App.xaml.cs
+++ b/Demo/App/App.xaml.cs
@@ -8,7 +8,7 @@ public App()
{
InitializeComponent();
- MainPage = new MainPage();
+ MainPage = new NavigationPage(new MainPage());
}
}
}
\ No newline at end of file
diff --git a/Demo/App/ButtonNotInScrollViewPage.xaml b/Demo/App/ButtonNotInScrollViewPage.xaml
new file mode 100644
index 0000000..855f37a
--- /dev/null
+++ b/Demo/App/ButtonNotInScrollViewPage.xaml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Demo/App/ButtonNotInScrollViewPage.xaml.cs b/Demo/App/ButtonNotInScrollViewPage.xaml.cs
new file mode 100644
index 0000000..0a443fe
--- /dev/null
+++ b/Demo/App/ButtonNotInScrollViewPage.xaml.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using Xamarin.Forms;
+using Xamarin.Forms.Xaml;
+
+namespace App
+{
+ [XamlCompilation(XamlCompilationOptions.Compile)]
+ public partial class ButtonNotInScrollViewPage : ContentPage
+ {
+ public ButtonNotInScrollViewPage()
+ {
+ InitializeComponent();
+ }
+
+ private async void StateButton_Clicked(object sender, EventArgs e)
+ {
+ await DisplayAlert("Clicked", string.Empty, "OK");
+ }
+
+ private async void StateButton_Released(object sender, EventArgs e)
+ {
+ await DisplayAlert("Release", string.Empty, "OK");
+ }
+ }
+}
\ No newline at end of file
diff --git a/Demo/App/MainPage.xaml b/Demo/App/MainPage.xaml
index 4bce074..a608e46 100644
--- a/Demo/App/MainPage.xaml
+++ b/Demo/App/MainPage.xaml
@@ -4,13 +4,16 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:app="clr-namespace:App;assembly=App"
xmlns:stateButton="clr-namespace:StateButton;assembly=StateButton"
- xmlns:xct="http://xamarin.com/schemas/2020/toolkit">
+ xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
+ NavigationPage.HasNavigationBar="False">
-
+
+
+
-
+
@@ -165,7 +168,7 @@
BackgroundColor="LightGray"
HeightRequest="1"
HorizontalOptions="Fill" />
-
+
@@ -193,7 +196,7 @@
BackgroundColor="LightGray"
HeightRequest="1"
HorizontalOptions="Fill" />
-
+
@@ -285,7 +288,7 @@
BackgroundColor="LightGray"
HeightRequest="1"
HorizontalOptions="Fill" />
-
+
diff --git a/Demo/App/MainPage.xaml.cs b/Demo/App/MainPage.xaml.cs
index 2cb4c82..1722d95 100644
--- a/Demo/App/MainPage.xaml.cs
+++ b/Demo/App/MainPage.xaml.cs
@@ -55,5 +55,10 @@ private async void NestButton_OnClicked(object sender, EventArgs e)
{
await DisplayAlert("Nested state button clicked", string.Empty, "OK");
}
+
+ private async void BtnNotInScrollView_Clicked(object sender, EventArgs e)
+ {
+ await Navigation.PushAsync(new ButtonNotInScrollViewPage());
+ }
}
}
\ No newline at end of file
diff --git a/Scr/StateButton.Android/StateButtonRenderer.cs b/Scr/StateButton.Android/StateButtonRenderer.cs
index c397e8b..26c3895 100644
--- a/Scr/StateButton.Android/StateButtonRenderer.cs
+++ b/Scr/StateButton.Android/StateButtonRenderer.cs
@@ -19,6 +19,7 @@ public StateButtonRenderer(Context context) : base(context)
SetAccessibilityDelegate(new MyAccessibilityDelegate());
}
+ private Rect rect;
protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);
@@ -33,9 +34,11 @@ protected override void OnElementChanged(ElementChangedEventArgs e)
Touch += (sender, te) =>
{
+ var v = (AndroidView.View)sender;
switch (te.Event.Action)
{
case MotionEventActions.Down:
+ rect = new Rect(v.Left, v.Top, v.Right, v.Bottom);
foreach (IGestureRecognizer recognizer in Element.GestureRecognizers.Where(x => x is TouchGestureRecognizer))
{
if (recognizer is TouchGestureRecognizer touchGestureRecognizer)
@@ -46,12 +49,20 @@ protected override void OnElementChanged(ElementChangedEventArgs e)
break;
case MotionEventActions.Up:
+
foreach (IGestureRecognizer recognizer in Element.GestureRecognizers.Where(x => x is TouchGestureRecognizer))
{
if (recognizer is TouchGestureRecognizer touchGestureRecognizer)
{
- touchGestureRecognizer.Released();
- touchGestureRecognizer.Clicked();
+ if (rect.Contains(v.Left + (int)te.Event.GetX(), v.Top + (int)te.Event.GetY()))
+ {
+ touchGestureRecognizer.Released();
+ touchGestureRecognizer.Clicked();
+ }
+ else
+ {
+ touchGestureRecognizer.Released();
+ }
}
}
break;
@@ -65,6 +76,18 @@ protected override void OnElementChanged(ElementChangedEventArgs e)
}
}
break;
+ case MotionEventActions.Move:
+ foreach (IGestureRecognizer recognizer in Element.GestureRecognizers.Where(x => x is TouchGestureRecognizer))
+ {
+ if (recognizer is TouchGestureRecognizer touchGestureRecognizer)
+ {
+ if (!rect.Contains(v.Left + (int)te.Event.GetX(), v.Top + (int)te.Event.GetY()))
+ {
+ touchGestureRecognizer.Released();
+ }
+ }
+ }
+ break;
}
};
}
diff --git a/Scr/StateButton/StateButton.xaml.cs b/Scr/StateButton/StateButton.xaml.cs
index bf397bf..4606c53 100644
--- a/Scr/StateButton/StateButton.xaml.cs
+++ b/Scr/StateButton/StateButton.xaml.cs
@@ -159,6 +159,8 @@ private void ReleasedGesture()
{
if (!IsEnabled) return;
+ if (State.Equals(ButtonStateEnum.NotPressed)) return;
+
Released?.Invoke(this, EventArgs.Empty);
ReleasedCommand?.Execute(ReleasedCommandParameter);
diff --git a/Settings.XamlStyler b/Settings.XamlStyler
new file mode 100644
index 0000000..36657ca
--- /dev/null
+++ b/Settings.XamlStyler
@@ -0,0 +1,41 @@
+{
+ "AttributesTolerance": 2,
+ "KeepFirstAttributeOnSameLine": true,
+ "MaxAttributeCharactersPerLine": 0,
+ "MaxAttributesPerLine": 1,
+ "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransfom, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter",
+ "SeparateByGroups": false,
+ "AttributeIndentation": 0,
+ "AttributeIndentationStyle": 1,
+ "RemoveDesignTimeReferences": false,
+ "EnableAttributeReordering": true,
+ "AttributeOrderingRuleGroups": [
+ "x:Class",
+ "xmlns, xmlns:x",
+ "xmlns:*",
+ "x:Key, Key, x:Name, Name, x:Uid, Uid, Title",
+ "Grid.Row, Grid.RowSpan, Grid.Column, Grid.ColumnSpan, Canvas.Left, Canvas.Top, Canvas.Right, Canvas.Bottom",
+ "Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight",
+ "Margin, Padding, HorizontalAlignment, VerticalAlignment, HorizontalContentAlignment, VerticalContentAlignment, Panel.ZIndex",
+ "*:*, *",
+ "PageSource, PageIndex, Offset, Color, TargetName, Property, Value, StartPoint, EndPoint",
+ "mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText",
+ "Storyboard.*, From, To, Duration"
+ ],
+ "FirstLineAttributes": "",
+ "OrderAttributesByName": true,
+ "PutEndingBracketOnNewLine": false,
+ "RemoveEndingTagOfEmptyElement": true,
+ "SpaceBeforeClosingSlash": true,
+ "RootElementLineBreakRule": 0,
+ "ReorderVSM": 2,
+ "ReorderGridChildren": false,
+ "ReorderCanvasChildren": false,
+ "ReorderSetters": 0,
+ "FormatMarkupExtension": true,
+ "NoNewLineMarkupExtensions": "x:Bind, Binding",
+ "ThicknessSeparator": 2,
+ "ThicknessAttributes": "Margin, Padding, BorderThickness, ThumbnailClipMargin",
+ "FormatOnSave": true,
+ "CommentPadding": 1
+}
\ No newline at end of file