[NUI] Add a protected virtual bool HitTest(Touch touch) method.
authorjoogab.yun <joogab.yun@samsung.com>
Sat, 12 Feb 2022 00:55:52 +0000 (09:55 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 15 Mar 2022 08:03:22 +0000 (17:03 +0900)
commite36906b247aeaf881add2c5ba85d6b52f7988341
tree2e1b7659d926ab8f1d1724acab8cdc4a360d3070
parent8fe1690c71510541673dbbc1ff0ffe1f2db0de3b
[NUI] Add a protected virtual bool HitTest(Touch touch) method.

In the case of TouchEvent or Gesture, there is no way to propagate the event to the view below that is not related.

So, in the hit-test process, called the virtual HitTest method to check whether it was hit or not.

User can override whether hit or not in HitTest.

If it returns false, it means that it will not be hit, and the hit-test continues to the next view.
If it returns true, it means that it was hit, and the touch/gesture event is called from the view as before.

for example)
Override HitTest as below.
HitTest() is called when the View is hit.
If returned false, This means it will not be hit. Then the hit-test goes to the next view.

class MyView : View
{
  protected override bool HitTest(Touch touch)
  {
    return false;
  }
}

class Sample
{
   public void Create()
   {
     View view = new MyView()
     {
       Size = new Size(100, 100),
     }
     view.TouchEvent += (s, e) =>
     {
       return false;
     }
   }
}
src/Tizen.NUI/src/internal/Interop/Interop.ActorSignal.cs
src/Tizen.NUI/src/public/BaseComponents/View.cs
src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs
src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs
test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/EventPropagationSample.cs [new file with mode: 0755]
test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/HitTestSample.cs [new file with mode: 0644]