/// <since_tizen> 6 </since_tizen>
public Button() : base()
{
+ Focusable = true;
}
/// <summary>
/// <since_tizen> 8 </since_tizen>
public Button(string style) : base(style)
{
+ Focusable = true;
}
/// <summary>
/// <since_tizen> 8 </since_tizen>
public Button(ButtonStyle buttonStyle) : base(buttonStyle)
{
+ Focusable = true;
}
/// <summary>
{
if (page is DialogPage == false)
{
- topPage.SetVisible(false);
+ topPage.SetVisible(false);
}
// Need to update Content of the new page
page.InvokeAppearing();
curTop.InvokeDisappearing();
+ //test.
+ // if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
+ // {
+ // curTop.LastFocusedView = FocusManager.Instance.GetCurrentFocusView();
+ // if(page.LastFocusedView)
+ // {
+ // FocusManager.Instance.SetCurrentFocusView(page.LastFocusedView);
+ // }
+ // else
+ // {
+ // FocusManager.Instance.ClearFocus();
+ // }
+ // }
+
//TODO: The following transition codes will be replaced with view transition.
InitializeAnimation();
//Invoke Page events
page.InvokeAppeared();
NotifyAccessibilityStatesChangeOfPages(curTop, page);
+
+ //test.
+ // if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
+ // {
+ // FocusManager.Instance.ClearFocus();
+ // FocusManager.Instance.MoveFocus(View.FocusDirection.Down);
+ // //FocusManager.Instance.MoveFocus(View.FocusDirection.Down);
+ // }
+
};
newAnimation.Play();
}
{
ShowContentOfPage(page);
}
+
+ //test.
+ // if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
+ // {
+ // FocusManager.Instance.ClearFocus();
+ // FocusManager.Instance.MoveFocus(View.FocusDirection.Down);
+ // FocusManager.Instance.MoveFocus(View.FocusDirection.Down);
+ // }
}
/// <summary>
newTop.InvokeAppearing();
curTop.InvokeDisappearing();
+ //test.
+ // if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
+ // {
+ // curTop.LastFocusedView = FocusManager.Instance.GetCurrentFocusView();
+ // if(newTop.LastFocusedView)
+ // {
+ // FocusManager.Instance.SetCurrentFocusView(newTop.LastFocusedView);
+ // }
+ // else
+ // {
+ // FocusManager.Instance.ClearFocus();
+ // }
+ // }
+
//TODO: The following transition codes will be replaced with view transition.
InitializeAnimation();
//Invoke Page events
newTop.InvokeAppeared();
+
+
+ //test.
+ // if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
+ // {
+ // FocusManager.Instance.ClearFocus();
+ // FocusManager.Instance.MoveFocus(View.FocusDirection.Down);
+ // //FocusManager.Instance.MoveFocus(View.FocusDirection.Down);
+ // }
+
+
};
newAnimation.Play();
}
Remove(curTop);
}
+ //test.
+ // if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
+ // {
+ // if(newTop.LastFocusedView)
+ // {
+ // FocusManager.Instance.SetCurrentFocusView(newTop.LastFocusedView);
+ // }
+ // }
+
+ // //test.
+ // if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
+ // {
+ // FocusManager.Instance.ClearFocus();
+ // FocusManager.Instance.MoveFocus(View.FocusDirection.Down);
+ // FocusManager.Instance.MoveFocus(View.FocusDirection.Down);
+ // }
+
return curTop;
}
RetrieveTaggedViews(taggedViewsInCurrentTopPage, currentTopPage, true);
List<KeyValuePair<View, View>> sameTaggedViewPair = new List<KeyValuePair<View, View>>();
- foreach(View currentTopPageView in taggedViewsInCurrentTopPage)
+ foreach (View currentTopPageView in taggedViewsInCurrentTopPage)
{
bool findPair = false;
- foreach(View newTopPageView in taggedViewsInNewTopPage)
+ foreach (View newTopPageView in taggedViewsInNewTopPage)
{
- if((currentTopPageView.TransitionOptions != null) && (newTopPageView.TransitionOptions != null) &&
+ if ((currentTopPageView.TransitionOptions != null) && (newTopPageView.TransitionOptions != null) &&
currentTopPageView.TransitionOptions?.TransitionTag == newTopPageView.TransitionOptions?.TransitionTag)
{
sameTaggedViewPair.Add(new KeyValuePair<View, View>(currentTopPageView, newTopPageView));
break;
}
}
- if(findPair)
+ if (findPair)
{
taggedViewsInNewTopPage.Remove(sameTaggedViewPair[sameTaggedViewPair.Count - 1].Value);
}
}
- foreach(KeyValuePair<View, View> pair in sameTaggedViewPair)
+ foreach (KeyValuePair<View, View> pair in sameTaggedViewPair)
{
taggedViewsInCurrentTopPage.Remove(pair.Key);
}
TransitionSet newTransitionSet = new TransitionSet();
- foreach(KeyValuePair<View, View> pair in sameTaggedViewPair)
+ foreach (KeyValuePair<View, View> pair in sameTaggedViewPair)
{
TransitionItem pairTransition = transition.CreateTransition(pair.Key, pair.Value, pushTransition);
- if(pair.Value.TransitionOptions?.TransitionWithChild ?? false)
+ if (pair.Value.TransitionOptions?.TransitionWithChild ?? false)
{
pairTransition.TransitionWithChild = true;
}
newTransitionSet.Finished += (object sender, EventArgs e) =>
{
- if(newTopPage.Layout != null)
+ if (newTopPage.Layout != null)
{
newTopPage.Layout.RequestLayout();
}
- if(currentTopPage.Layout != null)
+ if (currentTopPage.Layout != null)
{
currentTopPage.Layout.RequestLayout();
}
return instance.InternalDisappearingTransition;
});
+ internal BaseComponents.View LastFocusedView = null;
+
private Navigator navigator = null;
// Default transition is Fade.
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate void FocusedViewEnterKeyEventCallback2(IntPtr view);
+ private View internalFocusIndicator = null;
+
/// <summary>
/// PreFocusChange will be triggered before the focus is going to be changed.<br />
/// The FocusManager makes the best guess for which view to focus towards the given direction, but applications might want to change that.<br />
{
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);
- View ret = this.GetInstanceSafely<View>(cPtr);
- return ret;
+ internalFocusIndicator = this.GetInstanceSafely<View>(cPtr);
+ return internalFocusIndicator;
}
internal PreFocusChangeSignal PreFocusChangeSignal()
private Window window;
public void Activate()
{
- Log.Info(this.GetType().Name, $"@@@ this.GetType().Name={this.GetType().Name}, Activate()\n");
+ Log.Info(this.GetType().Name, $"this.GetType().Name={this.GetType().Name}, Activate()\n");
}
public void Deactivate()
{
- Log.Info(this.GetType().Name, $"@@@ this.GetType().Name={this.GetType().Name}, Deactivate()\n");
+ Log.Info(this.GetType().Name, $"this.GetType().Name={this.GetType().Name}, Deactivate()\n");
window = null;
}
{
Text = "Enabled"
};
- enabledButton.EnableFocus();
enabledButton.Clicked += (object obj, ClickedEventArgs ev) =>
{
Log.Info(this.GetType().Name, "Enabled Button Clicked\n");
Text = "Unselected",
IsSelectable = true,
};
- selectableButton.EnableFocus();
selectableButton.Clicked += (object obj, ClickedEventArgs ev) =>
{
Log.Info(this.GetType().Name, "Selected Button Clicked\n");
colorView.WidthSpecification = (isHorizontal? 200 : LayoutParamPolicies.MatchParent);
colorView.HeightSpecification = (isHorizontal? LayoutParamPolicies.MatchParent : 200);
colorView.BackgroundColor = new Color((float)rnd.Next(256)/256f, (float)rnd.Next(256)/256f, (float)rnd.Next(256)/256f, 1);
- colorView.EnableFocus();
scrollView.Add(colorView);
}
private List<DirectionOption> directionMenu;
public void Activate()
{
- Log.Info(this.GetType().Name, $"@@@ this.GetType().Name={this.GetType().Name}, Activate()\n");
+ Log.Info(this.GetType().Name, $"this.GetType().Name={this.GetType().Name}, Activate()\n");
}
public void Deactivate()
{
- Log.Info(this.GetType().Name, $"@@@ this.GetType().Name={this.GetType().Name}, Deactivate()\n");
+ Log.Info(this.GetType().Name, $"this.GetType().Name={this.GetType().Name}, Deactivate()\n");
window = null;
directionMenu = null;
}
};
item.Label.SetBinding(TextLabel.TextProperty, "Direction");
item.Label.HorizontalAlignment = HorizontalAlignment.Begin;
- item.EnableFocus();
return item;
}),
ScrollingDirection = ScrollableBase.Direction.Vertical,
Page scrollDirPage = new ScrollableBaseDirectionExample(directionItem.Direction);
window = NUIApplication.GetDefaultWindow();
window.GetDefaultNavigator().Push(scrollDirPage);
- FocusableExtension.SetFocusOnPage(scrollDirPage);
}
directionListView.SelectedItem = null;
};
namespace Tizen.NUI.StyleGuide
{
-
- /// Helder static extension class for Focusable.
- /// NUI default behavior is unfocusable in key or touch,
- /// this class help to setting focusable features easily.
- public static class FocusableExtension
- {
- public static FocusManager FocusManager;
- public static void EnableFocus(this View view)
- {
- view.Focusable = true;
- view.FocusableInTouch = true;
- }
-
- public static void EnableAutoFocusable()
- {
- FocusManager = FocusManager.Instance;
- FocusManager.EnableDefaultAlgorithm(true);
- 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),
- };
- }
-
- public static void SetFocusOnPage(Page page)
- {
- View focusCandidate = null;
- if (page == null) return;
-
- if (page is ContentPage contentPage)
- {
- focusCandidate = contentPage.AppBar?.NavigationContent;
- focusCandidate.Focusable = true;
- }
-
- if (focusCandidate == null)
- {
- foreach (View child in page.Children)
- {
- if (child.Focusable)
- {
- focusCandidate = child;
- }
- }
- }
-
- Log.Info("FocusableExtension", $"Focus candidate {focusCandidate}\n");
-
- if (focusCandidate != null)
- {
- FocusManager.SetCurrentFocusView(focusCandidate);
- }
- }
- }
-
public class SearchField : View
{
public TextField SearchTextField;
var searchTextBox = CreateSearchText();
SearchTextField = CreateTextField();
- SearchTextField.EnableFocus();
var underline = CreateUnderline();
searchTextBox.Add(SearchTextField);
searchTextBox.Add(underline);
SearchButton = CreateSearchButton();
- SearchButton.EnableFocus();
Add(searchTextBox);
Add(SearchButton);
WidthSpecification = LayoutParamPolicies.MatchParent,
HeightSpecification = LayoutParamPolicies.WrapContent,
MinimumSize = new Size2D(0, 40),
+ Focusable = true, //BaseComponents' Focusable is false as a default value, true should be set to navigate key focus and edit text.
};
}
foreach (Type type in assembly.GetTypes())
{
- Console.WriteLine($"@@@ type.Name={type.Name}, type.FullName={type.FullName}");
+ Console.WriteLine($"type.Name={type.Name}, type.FullName={type.FullName}");
if (exampleType.IsAssignableFrom(type) && type.Name != "SampleMain" && this.GetType() != type && type.IsClass)
{
NamePool.Add(new Tuple<string, string>(type.Name, type.FullName));
if (navigator.PageCount == 0)
{
- Exit();
+ Exit();
}
}
}
public void OnSelectionChanged(object sender, SelectionChangedEventArgs ev)
{
- Console.WriteLine($"@@@ OnSelectionChanged() {ev.CurrentSelection}");
+ Console.WriteLine($"OnSelectionChanged() {ev.CurrentSelection}");
if (ev.CurrentSelection.Count == 0) return;
if (ev.CurrentSelection[0] is ControlMenu selItem)
{
- Console.WriteLine($"@@@ selItem.Name={selItem.Name}, selItem.FullName={selItem.FullName}");
+ Console.WriteLine($"selItem.Name={selItem.Name}, selItem.FullName={selItem.FullName}");
RunSample(selItem?.FullName);
}
colView.SelectedItem = null;
base.OnCreate();
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);
}
private void Initialize()
{
window.Title = "NUI Style Guide";
window.KeyEvent += OnKeyEvent;
- FocusableExtension.EnableAutoFocusable();
-
navigator = window.GetDefaultNavigator();
navigator.Popped += (object obj, PoppedEventArgs ev) =>
{
Page top = navigator.Peek();
- FocusableExtension.SetFocusOnPage(top);
};
}
var appBarStyle = ThemeManager.GetStyle("Tizen.NUI.Components.AppBar");
var moreButton = new Button(((AppBarStyle)appBarStyle).BackButton);
moreButton.Icon.ResourceUrl = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "menu.png";
- moreButton.EnableFocus();
appBar.NavigationContent = moreButton;
};
item.Label.SetBinding(TextLabel.TextProperty, "ViewLabel");
item.Label.HorizontalAlignment = HorizontalAlignment.Begin;
- item.EnableFocus();
+ item.Focusable = true; //BaseComponents' Focusable is false as a default value, true should be set to navigate key focus.
return item;
}),
Header = myTitle,
AppBar = appBar,
Content = pageContent,
};
- page.Focusable = true;
navigator.Push(page);
- FocusableExtension.SetFocusOnPage(page);
}
private void RunSample(string name)
IExample example = typeof(Program).Assembly?.CreateInstance(name) as IExample;
- Console.WriteLine($"@@@ typeof(Program).Assembly={typeof(Program).Assembly}, name={name}");
+ Console.WriteLine($"typeof(Program).Assembly={typeof(Program).Assembly}, name={name}");
if (example != null)
{
example.Activate();
if (example is Page examplePage)
{
- examplePage.Focusable = true;
navigator.Push(examplePage);
- FocusableExtension.SetFocusOnPage(examplePage);
}
}
else
{
- Console.WriteLine($"@@@ examle is null!");
+ Console.WriteLine($"examle is null!");
}
}