CoreInputView.XYFocusTransferringFromPrimaryView Событие
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Происходит до того, как область ввода потеряет фокус и до того, как элемент пользовательского интерфейса получит фокус.
// Register
event_token XYFocusTransferringFromPrimaryView(TypedEventHandler<CoreInputView, CoreInputViewTransferringXYFocusEventArgs const&> const& handler) const;
// Revoke with event_token
void XYFocusTransferringFromPrimaryView(event_token const* cookie) const;
// Revoke with event_revoker
CoreInputView::XYFocusTransferringFromPrimaryView_revoker XYFocusTransferringFromPrimaryView(auto_revoke_t, TypedEventHandler<CoreInputView, CoreInputViewTransferringXYFocusEventArgs const&> const& handler) const;
public event TypedEventHandler<CoreInputView,CoreInputViewTransferringXYFocusEventArgs> XYFocusTransferringFromPrimaryView;
function onXYFocusTransferringFromPrimaryView(eventArgs) { /* Your code */ }
coreInputView.addEventListener("xyfocustransferringfromprimaryview", onXYFocusTransferringFromPrimaryView);
coreInputView.removeEventListener("xyfocustransferringfromprimaryview", onXYFocusTransferringFromPrimaryView);
- or -
coreInputView.onxyfocustransferringfromprimaryview = onXYFocusTransferringFromPrimaryView;
Public Custom Event XYFocusTransferringFromPrimaryView As TypedEventHandler(Of CoreInputView, CoreInputViewTransferringXYFocusEventArgs)
Тип события
Требования к Windows
Семейство устройств |
Windows 10, version 1803 (появилось в 10.0.17134.0)
|
API contract |
Windows.Foundation.UniversalApiContract (появилось в v6.0)
|
Примеры
Здесь мы покажем, как обрабатывать событие XYFocusTransferringFromPrimaryView и определять, какой элемент пользовательского интерфейса должен получить фокус в приложении. Кандидаты фокуса различаются по расположению относительно ограничивающего прямоугольника последнего дочернего элемента области ввода.
private void OnXYFocusTransferringFromPrimaryView(CoreInputView sender,
CoreInputViewTransferringXYFocusEventArgs args)
{
bool acceptXYFocusTransfer = false;
switch (args.Direction)
{
case CoreInputViewXYFocusTransferDirection.Down:
// If focus navigation is moving down,
// set focus to the top element (usernameTextBox).
this.usernameTextBox.Focus(FocusState.Programmatic);
acceptXYFocusTransfer = true;
break;
case CoreInputViewXYFocusTransferDirection.Up:
// If focus navigation is moving up,
// there are two focus candidates.
// Check the Origin rect to determine the more
// suitable candidate.
if ((args.Origin.X + (args.Origin.Width / 2.0)) <
Window.Current.Bounds.Width / 2.0)
{
this.cancelButton.Focus(FocusState.Programmatic);
}
else
{
this.submitButton.Focus(FocusState.Programmatic);
}
acceptXYFocusTransfer = true;
break;
case CoreInputViewXYFocusTransferDirection.Left:
case CoreInputViewXYFocusTransferDirection.Right:
// If focus navigation is moving left or right,
// maintain focus on the currently focused UI element.
acceptXYFocusTransfer = true;
break;
default:
// Don't accept XY focus movement.
break;
}
if (acceptXYFocusTransfer)
{
args.TransferHandled = true;
this.KeyDown += OnMainPageKeyDown;
}
}
Комментарии
Основное представление относится к любому из представлений CoreInputViewKind.Keyboard или CoreInputViewKind.Handwriting , в то время как CoreInputView может быть любым из значений CoreInputViewKind.
Назначьте целевой объект фокуса при переходе из области ввода к элементу пользовательского интерфейса в приложении.