// Initialize DisposeQueue Singleton class. This is also required to create DisposeQueue on main thread.
DisposeQueue.Instance.Initialize();
Window.Instance = GetWindow();
+ _ = FocusManager.Instance;
// Notify that the window is displayed to the app core.
if (NUIApplication.IsPreload)
private delegate void FocusedViewEnterKeyEventCallback2(IntPtr view);
private View internalFocusIndicator = null;
+ private View nullFocusIndicator = null;
/// <summary>
/// PreFocusChange will be triggered before the focus is going to be changed.<br />
{
set
{
- SetFocusIndicatorView(value);
+ internalFocusIndicator = value;
+ if (internalFocusIndicator == null)
+ {
+ if (nullFocusIndicator == null)
+ {
+ nullFocusIndicator = new View();
+ }
+ SetFocusIndicatorView(nullFocusIndicator);
+ }
+ else
+ {
+ SetFocusIndicatorView(internalFocusIndicator);
+ }
}
get
{
- return GetFocusIndicatorView();
+ return internalFocusIndicator;
}
}
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
+ /// <summary>
+ /// Get a default focus indicator
+ /// </summary>
+ /// <remarks>
+ /// The type actually <see cref="Tizen.NUI.BaseComponents.ImageView"/> of blue border squred png image, so it would be difficult to modify itself.
+ /// To change focus indicator, creating new indicator and assigning it to FocusIndicator are recommended.
+ /// For example,
+ /// <code>
+ /// FocusManager.Instance.FocusIndicator = new View()
+ /// {
+ /// PositionUsesPivotPoint = true,
+ /// PivotPoint = new Position(0, 0, 0),
+ /// WidthResizePolicy = ResizePolicyType.FillToParent,
+ /// HeightResizePolicy = ResizePolicyType.FillToParent,
+ /// BorderlineColor = Color.Orange,
+ /// BorderlineWidth = 4.0f,
+ /// BorderlineOffset = -1f,
+ /// BackgroundColor = new Color(0.2f, 0.2f, 0.2f, 0.2f),
+ /// };
+ /// </code>
+ /// </remarks>
+ /// <returns>instance of default focus indicator</returns>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public View GetDefaultFocusIndicator()
+ {
+ ImageView ret = new ImageView(FrameworkInformation.ResourcePath + "keyboard_focus.9.png")
+ {
+ Name = "DefaultFocusIndicatorCreatedByNUI",
+ PositionUsesAnchorPoint = true,
+ ParentOrigin = ParentOrigin.Center,
+ PivotPoint = ParentOrigin.Center,
+ Position2D = new Position2D(0, 0),
+ };
+ ret.SetResizePolicy(ResizePolicyType.FillToParent, DimensionType.AllDimensions);
+ return ret;
+ }
+
internal static FocusManager Get()
{
FocusManager ret = new FocusManager(Interop.FocusManager.Get(), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+
+ ret.FocusIndicator = ret.GetDefaultFocusIndicator();
return ret;
}
{
Interop.FocusManager.SetFocusIndicatorActor(SwigCPtr, View.getCPtr(indicator));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- internalFocusIndicator = indicator;
}
internal View GetFocusIndicatorView()
{
//to fix memory leak issue, match the handle count with native side.
IntPtr cPtr = Interop.FocusManager.GetFocusIndicatorActor(SwigCPtr);
- internalFocusIndicator = this.GetInstanceSafely<View>(cPtr);
- return internalFocusIndicator;
+ return this.GetInstanceSafely<View>(cPtr);
}
internal PreFocusChangeSignal PreFocusChangeSignal()
Text = "OK",
};
- button.Clicked += (object s, ClickedEventArgs a) =>
+ button.Clicked += (object sender, ClickedEventArgs args) =>
{
Navigator?.Pop();
};
Text = "Cancel",
};
- button.Clicked += (object s, ClickedEventArgs a) =>
+ button.Clicked += (object sender, ClickedEventArgs args) =>
{
Navigator?.Pop();
};
Text = "OK",
};
- button2.Clicked += (object s, ClickedEventArgs a) =>
+ button2.Clicked += (object sender, ClickedEventArgs args) =>
{
Navigator?.Pop();
};
Text = "Cancel",
};
- button.Clicked += (object s, ClickedEventArgs a) =>
+ button.Clicked += (object sender, ClickedEventArgs args) =>
{
Navigator?.Pop();
};
Text = "OK",
};
- button2.Clicked += (object s, ClickedEventArgs a) =>
+ button2.Clicked += (object sender, ClickedEventArgs args) =>
{
Navigator?.Pop();
};
Text = "Cancel",
};
- button.Clicked += (object s, ClickedEventArgs a) =>
+ button.Clicked += (object sender, ClickedEventArgs args) =>
{
Navigator?.Pop();
};
Text = "OK",
};
- button2.Clicked += (object s, ClickedEventArgs a) =>
+ button2.Clicked += (object sender, ClickedEventArgs args) =>
{
Navigator?.Pop();
};
--- /dev/null
+/*
+ * Copyright(c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+using System;
+using System.ComponentModel;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+
+namespace Tizen.NUI.StyleGuide
+{
+ // IExample inehrited class will be automatically added in the main examples list.
+ internal class FocusIndicatorTest : ContentPage, IExample
+ {
+ private View rootContent;
+ private Button buttonSetNewIndi, buttonRestoreIndi, buttonSetNull;
+ private FocusManager focusmanager;
+
+
+ public void Activate()
+ {
+ }
+ public void Deactivate()
+ {
+ }
+
+ /// Modify this method for adding other examples.
+ public FocusIndicatorTest() : base()
+ {
+ focusmanager = FocusManager.Instance;
+
+ WidthSpecification = LayoutParamPolicies.MatchParent;
+ HeightSpecification = LayoutParamPolicies.MatchParent;
+
+ // Navigator bar title is added here.
+ AppBar = new AppBar()
+ {
+ Title = "Focus Indicator Test",
+ };
+
+ // Example root content view.
+ // you can decorate, add children on this view.
+ rootContent = new View()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ CellPadding = new Size2D(10, 20),
+ },
+ };
+
+ buttonSetNewIndi = new Button
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ Text = "Set New Focus Indicator",
+ };
+ rootContent.Add(buttonSetNewIndi);
+
+ buttonSetNewIndi.Clicked += (s, e) =>
+ {
+ focusmanager.FocusIndicator = new View()
+ {
+ PositionUsesPivotPoint = true,
+ PivotPoint = new Position(0, 0, 0),
+ WidthResizePolicy = ResizePolicyType.FillToParent,
+ HeightResizePolicy = ResizePolicyType.FillToParent,
+ BorderlineColor = Color.Orange,
+ BorderlineWidth = 4.0f,
+ BorderlineOffset = -1f,
+ BackgroundColor = new Color(0.2f, 0.2f, 0.2f, 0.2f),
+ };
+ };
+
+ buttonSetNull = new Button
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ Text = "Set null Focus Indicator",
+ };
+ rootContent.Add(buttonSetNull);
+
+ buttonSetNull.Clicked += (s, e) =>
+ {
+ focusmanager.FocusIndicator = null;
+ };
+
+ buttonRestoreIndi = new Button
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ Text = "Restore default Focus Indicator",
+ };
+ rootContent.Add(buttonRestoreIndi);
+
+ buttonRestoreIndi.Clicked += (s, e) =>
+ {
+ focusmanager.FocusIndicator = focusmanager.GetDefaultFocusIndicator();
+ };
+
+ Content = rootContent;
+ }
+ }
+}
private ContentPage page;
private SearchField field;
private List<ControlMenu> testSource;
- private FocusManager focusManager;
public void OnKeyEvent(object sender, Window.KeyEventArgs e)
{
Initialize();
SetMainPage();
- focusManager = FocusManager.Instance;
-
- //set user customized focus indicator
- if (!focusManager.FocusIndicator)
- {
- focusManager.FocusIndicator = new View()
- {
- PositionUsesPivotPoint = true,
- PivotPoint = new Position(0, 0, 0),
- WidthResizePolicy = ResizePolicyType.FillToParent,
- HeightResizePolicy = ResizePolicyType.FillToParent,
- BorderlineColor = Color.Orange,
- BorderlineWidth = 4.0f,
- BorderlineOffset = -1f,
- BackgroundColor = new Color(0.2f, 0.2f, 0.2f, 0.2f),
- };
- }
-
//enable FocusManger default algorithm
- focusManager.EnableDefaultAlgorithm(true);
+ FocusManager.Instance.EnableDefaultAlgorithm(true);
}
private void Initialize()
{
<ItemGroup>
<ProjectReference Include="../../src/Tizen.NUI.Components/Tizen.NUI.Components.csproj" />
<ProjectReference Include="../../src/Tizen.NUI/Tizen.NUI.csproj" />
+ <PackageReference Include="Tizen.NET.Sdk" Version="1.0.9" />
</ItemGroup>
</Project>