From e50403acb70e0e9a4968c2908b6d0b1a7a038c04 Mon Sep 17 00:00:00 2001 From: Joogab Yun Date: Fri, 4 Jun 2021 12:05:43 +0900 Subject: [PATCH] [NUI] Add FocusableInTouch property This is a property that allows you to have focus even when touched. If Focusable is false, FocusableInTouchMode is disabled. If you want to have focus on touch in touch mode, you need to set both settings to true. focusable = true, focusableInTouch = true, --- .../src/internal/Interop/Interop.ActorInternal.cs | 6 ++++++ .../src/public/BaseComponents/Style/ViewStyle.cs | 13 +++++++++++++ .../Style/ViewStyleBindableProperty.cs | 7 +++++++ src/Tizen.NUI/src/public/BaseComponents/View.cs | 19 +++++++++++++++++++ .../public/BaseComponents/ViewBindableProperty.cs | 21 ++++++++++++++++++--- .../src/public/BaseComponents/ViewInternal.cs | 15 +++++++++++++++ 6 files changed, 78 insertions(+), 3 deletions(-) diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.ActorInternal.cs b/src/Tizen.NUI/src/internal/Interop/Interop.ActorInternal.cs index 42fc88c..4a2367d 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.ActorInternal.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.ActorInternal.cs @@ -195,6 +195,12 @@ namespace Tizen.NUI [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Actor_IsKeyboardFocusable")] public static extern bool IsKeyboardFocusable(global::System.Runtime.InteropServices.HandleRef jarg1); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Actor_SetTouchFocusable")] + public static extern void SetFocusableInTouch(global::System.Runtime.InteropServices.HandleRef jarg1, bool jarg2); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Actor_IsTouchFocusable")] + public static extern bool IsFocusableInTouch(global::System.Runtime.InteropServices.HandleRef jarg1); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Actor_SetSizeScalePolicy")] public static extern void SetSizeScalePolicy(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2); diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs index 84bf967..899473d 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs @@ -29,6 +29,7 @@ namespace Tizen.NUI.BaseComponents { private bool disposed = false; private bool? focusable; + private bool? focusableInTouch; private bool? positionUsesPivotPoint; private Position parentOrigin; private Position pivotPoint; @@ -106,6 +107,18 @@ namespace Tizen.NUI.BaseComponents set => SetValue(FocusableProperty, value); } + /// + /// Whether this view can focus by touch. + /// If Focusable is false, FocusableInTouch is disabled. + /// If you want to have focus on touch, you need to set both Focusable and FocusableInTouch settings to true. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool? FocusableInTouch + { + get => (bool?)GetValue(FocusableInTouchProperty); + set => SetValue(FocusableInTouchProperty, value); + } + /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [Obsolete("Deprecated. Please use Size instead.")] [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyleBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyleBindableProperty.cs index 1253462..12fb8ec 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyleBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyleBindableProperty.cs @@ -49,6 +49,13 @@ namespace Tizen.NUI.BaseComponents defaultValueCreator: (bindable) => ((ViewStyle)bindable).focusable ); + /// Bindable property of FocusableInTouch. Please do not open it. + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty FocusableInTouchProperty = BindableProperty.Create(nameof(FocusableInTouch), typeof(bool?), typeof(ViewStyle), null, + propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).focusableInTouch = (bool?)newValue, + defaultValueCreator: (bindable) => ((ViewStyle)bindable).focusableInTouch + ); + /// Bindable property of Focusable. Please do not open it. [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty Size2DProperty = BindableProperty.Create(nameof(Size2D), typeof(Size2D), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index 72a36ad..477ba55 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -912,6 +912,25 @@ namespace Tizen.NUI.BaseComponents } /// + /// Whether this view can focus by touch. + /// If Focusable is false, FocusableInTouch is disabled. + /// If you want to have focus on touch, you need to set both Focusable and FocusableInTouch settings to true. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool FocusableInTouch + { + set + { + SetValue(FocusableInTouchProperty, value); + NotifyPropertyChanged(); + } + get + { + return (bool)GetValue(FocusableInTouchProperty); + } + } + + /// /// Retrieves the position of the view.
/// The coordinates are relative to the view's parent.
///
diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs index de59832..5452fc0 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs @@ -574,6 +574,21 @@ namespace Tizen.NUI.BaseComponents }); /// + /// FocusableInTouchProperty + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty FocusableInTouchProperty = BindableProperty.Create(nameof(FocusableInTouch), typeof(bool), typeof(View), false, propertyChanged: (bindable, oldValue, newValue) => + { + var view = (View)bindable; + if (newValue != null) { view.SetFocusableInTouch((bool)newValue); } + }, + defaultValueCreator: (bindable) => + { + var view = (View)bindable; + return view.IsFocusableInTouch(); + }); + + /// /// Size2DProperty /// [EditorBrowsable(EditorBrowsableState.Never)] @@ -1515,7 +1530,7 @@ namespace Tizen.NUI.BaseComponents } else { - view.SetShadow((ImageShadow)newValue); + view.SetShadow((ImageShadow)newValue); } }), defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) => @@ -1546,7 +1561,7 @@ namespace Tizen.NUI.BaseComponents } else { - view.SetShadow((Shadow)newValue); + view.SetShadow((Shadow)newValue); } }), defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) => @@ -1909,7 +1924,7 @@ namespace Tizen.NUI.BaseComponents .Add(Visual.Property.BorderlineWidth, new PropertyValue(backgroundExtraData.BorderlineWidth)) .Add(Visual.Property.BorderlineColor, new PropertyValue(backgroundExtraData.BorderlineColor == null ? new PropertyValue(Color.Black) : new PropertyValue(backgroundExtraData.BorderlineColor))) .Add(Visual.Property.BorderlineOffset, new PropertyValue(backgroundExtraData.BorderlineOffset)); - + Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)SwigCPtr, View.Property.BACKGROUND, new PropertyValue(map)); } diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs index 73f571a..cc15e30 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs @@ -926,6 +926,21 @@ namespace Tizen.NUI.BaseComponents return ret; } + internal void SetFocusableInTouch(bool enabled) + { + Interop.ActorInternal.SetFocusableInTouch(SwigCPtr, enabled); + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + internal bool IsFocusableInTouch() + { + bool ret = Interop.ActorInternal.IsFocusableInTouch(SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension) { Interop.Actor.SetResizePolicy(SwigCPtr, (int)policy, (int)dimension); -- 2.7.4