1
This commit is contained in:
@@ -23,12 +23,18 @@ namespace BITKit.UX
|
||||
{
|
||||
name = "tabs"
|
||||
};
|
||||
private readonly UxmlBoolAttributeDescription m_allowFocus = new ()
|
||||
{
|
||||
name = "allowFocus",
|
||||
defaultValue = true
|
||||
};
|
||||
public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
|
||||
{
|
||||
base.Init(ve, bag, cc);
|
||||
var tabBar = (TabBar)ve;
|
||||
tabBar.CurrentTab = m_TabBarAttribute.GetValueFromBag(bag, cc);
|
||||
tabBar.Tabs = m_TabsAttribute.GetValueFromBag(bag, cc);
|
||||
tabBar.allowFocus = m_allowFocus.GetValueFromBag(bag, cc);
|
||||
}
|
||||
}
|
||||
public new class UxmlFactory : UxmlFactory<TabBar, UxmlTraits> { }
|
||||
@@ -58,6 +64,22 @@ namespace BITKit.UX
|
||||
SetTabs(value);
|
||||
}
|
||||
}
|
||||
|
||||
private bool allowFocus;
|
||||
public bool AllowFocus
|
||||
{
|
||||
get => allowFocus;
|
||||
set
|
||||
{
|
||||
allowFocus = value;
|
||||
foreach (var x in _buttons)
|
||||
{
|
||||
x.focusable = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void SetTabs(string value)
|
||||
{
|
||||
var split = value.Split(",");
|
||||
@@ -72,6 +94,7 @@ namespace BITKit.UX
|
||||
var index = i;
|
||||
var button = _buttons[i] = this.Create<Button>();
|
||||
button.text = tabName;
|
||||
button.focusable = allowFocus;
|
||||
button.clicked += () => CurrentTab = index;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user