This aligns the behaviour of Components (derived from CustomView), and other controls, with that
of BaseComponents (and other controls with ViewAccessibilityMode.Default, backed by the C++
accessibility implementation), which set the keyboard focus on activation. Please note that in the
latter case, the implementation of View.OnAccessibilityActivated is unused, and the unrelated method
(albeit bearing the same name) Toolkit::Control::OnAccessibilityActivated is called:
bool Control::OnAccessibilityActivated()
{
if(Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor(Self()))
{
return OnKeyboardEnter();
}
return false;
}
So, in other words, this patch makes C# controls behave in a similar manner, i.e. set the keyboard
focus on accessibility activation.
[EditorBrowsable(EditorBrowsableState.Never)]
protected override bool OnAccessibilityActivated()
{
+ if (!base.OnAccessibilityActivated())
+ {
+ return false;
+ }
+
return OnKeyboardEnter();
}
[EditorBrowsable(EditorBrowsableState.Never)]
protected virtual bool OnAccessibilityActivated()
{
- return false;
+ return FocusManager.Instance.SetCurrentFocusView(this);
}
/// <summary>