Skip to content

Commit

Permalink
[NUI] Fix ImageButton Clicked (dotnet#523)
Browse files Browse the repository at this point in the history
* Fix ImageButton Clicked

* Apply review comment
  • Loading branch information
myroot committed Aug 25, 2022
1 parent 88ecdee commit 868ba09
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Core/src/Platform/Tizen/MauiImageButton.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using Tizen.NUI;
using Tizen.UIExtensions.NUI;
using NColor = Tizen.NUI.Color;
using TImage = Tizen.UIExtensions.NUI.Image;

Expand All @@ -16,6 +17,7 @@ public class MauiImageButton : TImage
public MauiImageButton()
{
TouchEvent += OnTouched;
KeyEvent += OnKeyEvent;
Border = Border = new Rectangle(0, 0, 0, 0);
}

Expand Down Expand Up @@ -48,7 +50,7 @@ bool OnTouched(object source, TouchEventArgs e)
else if (state == PointStateType.Up)
{
Released?.Invoke(this, EventArgs.Empty);
if (_isPressed)
if (_isPressed && this.IsInside(e.Touch.GetLocalPosition(0)))
{
Clicked?.Invoke(this, EventArgs.Empty);
}
Expand All @@ -57,5 +59,15 @@ bool OnTouched(object source, TouchEventArgs e)
}
return false;
}

bool OnKeyEvent(object source, KeyEventArgs e)
{
if (e.Key.IsAcceptKeyEvent())
{
Clicked?.Invoke(this, EventArgs.Empty);
return true;
}
return false;
}
}
}

0 comments on commit 868ba09

Please sign in to comment.