From c44dbadd704faf86d672c31949cdce6489cde24c Mon Sep 17 00:00:00 2001 From: huiyueun <35286162+huiyueun@users.noreply.github.com> Date: Wed, 19 Jun 2019 09:49:48 +0900 Subject: [PATCH] [NUI] Fix ConvertidToView issue (#890) * [NUI] Fix ConvertIdToView (#877) Signed-off-by: huiyu.eun * [NUI] Fix ConvertIdToView issue If we can't find the parent's children, find in the top layer. Signed-off-by: huiyu.eun --- .../src/public/BaseComponents/View.cs | 26 +++++++++++++------ src/Tizen.NUI/src/public/Container.cs | 2 ++ src/Tizen.NUI/src/public/Layer.cs | 5 ++++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index 883a1b893..feed4476b 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -4611,6 +4611,11 @@ namespace Tizen.NUI.BaseComponents return ret; } + internal override View FindCurrentChildById(uint id) + { + return FindChildById(id); + } + internal void SetParentOrigin(Vector3 origin) { Interop.ActorInternal.Actor_SetParentOrigin(swigCPtr, Vector3.getCPtr(origin)); @@ -5595,16 +5600,21 @@ namespace Tizen.NUI.BaseComponents private View ConvertIdToView(uint id) { - View view = null; - if (GetParent() is View) - { - View parentView = GetParent() as View; - view = parentView.FindChildById(id); - } + View view = GetParent()?.FindCurrentChildById(id); - if (!view) + //If we can't find the parent's children, find in the top layer. + if (!view) { - view = Window.Instance.GetRootLayer().FindChildById(id); + Container parent = GetParent(); + while ((parent is View) && (parent != null)) + { + parent = parent.GetParent(); + if (parent is Layer) + { + view = parent.FindCurrentChildById(id); + break; + } + } } return view; diff --git a/src/Tizen.NUI/src/public/Container.cs b/src/Tizen.NUI/src/public/Container.cs index 2c05dc60e..4971a4e6d 100755 --- a/src/Tizen.NUI/src/public/Container.cs +++ b/src/Tizen.NUI/src/public/Container.cs @@ -135,5 +135,7 @@ namespace Tizen.NUI base.Dispose(type); } + internal abstract View FindCurrentChildById(uint id); + } } // namespace Tizen.NUI diff --git a/src/Tizen.NUI/src/public/Layer.cs b/src/Tizen.NUI/src/public/Layer.cs index cd5f37014..93f698e0b 100755 --- a/src/Tizen.NUI/src/public/Layer.cs +++ b/src/Tizen.NUI/src/public/Layer.cs @@ -382,6 +382,11 @@ namespace Tizen.NUI return ret; } + internal override View FindCurrentChildById(uint id) + { + return FindChildById(id); + } + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public View FindChildByName(string viewName) -- 2.34.1