private void DataGridMethods_CharacterReceived(UIElement sender, CharacterReceivedRoutedEventArgs args) { if (args.KeyStatus.ScanCode > 1) { if (args.KeyStatus.ScanCode == 14) { ParametersSearch.Text = ParametersSearch.Text.RemoveChars(1); } else { string pathColumn = ((DataGrid)sender).CurrentColumn?.ClipboardContentBinding.Path.Path; switch (pathColumn) { case "Group": ParametersSearch.SearchInGroup = true; break; case "Type": ParametersSearch.SearchInType = true; break; case "ObjectName": ParametersSearch.SearchInObjectName = true; break; case "MethodName": ParametersSearch.SearchInMethodName = true; break; } ParametersSearch.Text += args.Character.ToString(); } } }
private void WorkingDirectory_CharReceived(UIElement sender, CharacterReceivedRoutedEventArgs args) { if (args.Character == '\r') { CommandLine.Focus(FocusState.Keyboard); } }
private void OnCharacterReceived(UIElement sender, CharacterReceivedRoutedEventArgs args) { //System.Diagnostics.Debug.WriteLine("HardwareKeyListenerEffect.OnCharacterReceived("+Element+")"); if (Element is VisualElement element) { args.Handled = HardwareKeyPageRenderer.ProcessCharacter(element, args.Character); } }
private void Content_CharacterReceived(UIElement sender, CharacterReceivedRoutedEventArgs args) { if (ParentShellPageInstance.IsCurrentInstance) { char letterPressed = args.Character; ParentShellPageInstance.InteractionOperations.PushJumpChar(letterPressed); } }
private void AutoSuggestBox_CharacterReceived(UIElement sender, CharacterReceivedRoutedEventArgs args) { if (args.Character.ToString() == TokenDelimiter && sender is AutoSuggestBox autoSuggestBox) { AddToken(autoSuggestBox.Text); autoSuggestBox.Text = string.Empty; autoSuggestBox.Focus(FocusState.Programmatic); } }
private async void OnCodeEditorCharacterReceived(UIElement sender, CharacterReceivedRoutedEventArgs e) { if (e.Character == '.' || IsValidCSharpIdentifierCharacter(e.Character)) { await ShowCompletionListAsync(); } else { CompletionListFlyout.Hide(); } }
private void RichEditBox_CharacterReceived(UIElement sender, CharacterReceivedRoutedEventArgs args) { Color defaultColor = Colors.Black; if (_syntaxHighlight.TryGetValue(args.Character, out Color color)) { DefineColor(BrainfuckInputRichTextBox, color); } else if (args.Character != '\b') { DefineColor(BrainfuckInputRichTextBox, defaultColor); } args.Handled = false; }
private async void TextBox_CharacterReceived(UIElement sender, CharacterReceivedRoutedEventArgs args) { IEnumerable <IGalleryItem> gallery; if (Search.Text == "") { gallery = await ImgurApi.GetGallery(); } else { gallery = await ImgurApi.SearchGallery(Search.Text, _user); } _images.Clear(); AddGalleryView(gallery); }
protected override void OnCharacterReceived(CharacterReceivedRoutedEventArgs e) { if (ParentShellPageInstance != null) { if (ParentShellPageInstance.CurrentPageType == typeof(GenericFileBrowser)) { // Don't block the various uses of enter key (key 13) var focusedElement = FocusManager.GetFocusedElement() as FrameworkElement; if (e.Character == (char)13 || focusedElement is Button || focusedElement is TextBox || focusedElement is PasswordBox || Interaction.FindParent <ContentDialog>(focusedElement) != null) { return; } base.OnCharacterReceived(e); AllView.Focus(FocusState.Keyboard); } } }
// Handles inputs from TextBox private void TextBoxHandler(UIElement element, CharacterReceivedRoutedEventArgs argument) { if (((TextBox)element).Text.Length == 0) { return; } // if nothing is entered, don't do anything if (argument.Character.GetHashCode() == 851981) // If user presses enter into the textbox { double value; if (double.TryParse(((TextBox)element).Text, out value)) { ChangeSimulation(element, value); } } else if (!Char.IsNumber(argument.Character) && !argument.Character.Equals('.') && !argument.Character.Equals('\b') && !argument.Character.Equals('-')) // If the user input isn't a number then remove it { ((TextBox)element).Text = ((TextBox)element).Text.Substring(0, ((TextBox)element).Text.Length - 1); } }
/// <summary> /// Gets a value that marks the routed event as handled. A <c>true</c> value for <see cref="CharacterReceivedRoutedEventArgs.Handled"/> /// prevents most handlers along the event route from handling the same event again. /// </summary> /// <param name="e">The requested <see cref="CharacterReceivedRoutedEventArgs"/>.</param> /// <returns> /// <c>true</c> to mark the routed event handled. <c>false</c> to leave the routed event unhandled, /// which permits the event to potentially route further and be acted on by other handlers. /// The default is <c>false</c>. /// </returns> public static bool Handled(this CharacterReceivedRoutedEventArgs e) => Resolver.Handled(e);
/// <summary> /// Sets a value that marks the routed event as handled. A <c>true</c> value for <see cref="CharacterReceivedRoutedEventArgs.Handled"/> /// prevents most handlers along the event route from handling the same event again. /// </summary> /// <param name="e">The requested <see cref="CharacterReceivedRoutedEventArgs"/>.</param> /// <param name="handled"> /// <c>true</c> to mark the routed event handled. <c>false</c> to leave the routed event unhandled, /// which permits the event to potentially route further and be acted on by other handlers. /// The default is <c>false</c>. /// </param> public static void Handled(this CharacterReceivedRoutedEventArgs e, bool handled) => Resolver.Handled(e, handled);
/// <summary> /// Gets a reference to the object that raised the event. /// This is often a template part of a control rather than an element that was declared in your app UI. /// </summary> /// <param name="e">The requested <see cref="CharacterReceivedRoutedEventArgs"/>.</param> /// <returns>The object that raised the event.</returns> public static object OriginalSource(CharacterReceivedRoutedEventArgs e) => Resolver.OriginalSource(e);
private void Content_CharacterReceived(UIElement sender, CharacterReceivedRoutedEventArgs args) { CharacterReceived?.Invoke(args.Character); }
char ICharacterReceivedRoutedEventArgsResolver.Character(CharacterReceivedRoutedEventArgs e) => e.Character;
/// <summary> /// Gets the status of the physical key that raised the character-received event. /// </summary> /// <param name="e">The requested <see cref="CharacterReceivedRoutedEventArgs"/>.</param> /// <returns>The status of the key that was pressed.</returns> public static CorePhysicalKeyStatus KeyStatus(this CharacterReceivedRoutedEventArgs e) => Resolver.KeyStatus(e);
CorePhysicalKeyStatus ICharacterReceivedRoutedEventArgsResolver.KeyStatus(CharacterReceivedRoutedEventArgs e) => e.KeyStatus;
private void tbPassword_CharacterReceived(UIElement sender, CharacterReceivedRoutedEventArgs args) { }
object ICharacterReceivedRoutedEventArgsResolver.OriginalSource(CharacterReceivedRoutedEventArgs e) => e.OriginalSource;
void ICharacterReceivedRoutedEventArgsResolver.Handled(CharacterReceivedRoutedEventArgs e, bool handled) => e.Handled = handled;
bool ICharacterReceivedRoutedEventArgsResolver.Handled(CharacterReceivedRoutedEventArgs e) => e.Handled;
private async void TokenizingTextBox_CharacterReceived(UIElement sender, CharacterReceivedRoutedEventArgs args) { var container = ContainerFromItem(_currentTextEdit) as TokenizingTextBoxItem; if (container != null && !(GetFocusedElement().Equals(container._autoSuggestTextBox) || char.IsControl(args.Character))) { if (SelectedItems.Count > 0) { var index = _innerItemsSource.IndexOf(SelectedItems.First()); await RemoveAllSelectedTokens(); // Wait for removal of old items _ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { // If we're before the last textbox and it's empty, redirect focus to that one instead if (index == _innerItemsSource.Count - 1 && string.IsNullOrWhiteSpace(_lastTextEdit.Text)) { var lastContainer = ContainerFromItem(_lastTextEdit) as TokenizingTextBoxItem; lastContainer.UseCharacterAsUser = true; // Make sure we trigger a refresh of suggested items. _lastTextEdit.Text = string.Empty + args.Character; UpdateCurrentTextEdit(_lastTextEdit); lastContainer._autoSuggestTextBox.SelectionStart = 1; // Set position to after our new character inserted lastContainer._autoSuggestTextBox.Focus(FocusState.Keyboard); } else { //// Otherwise, create a new textbox for this text. UpdateCurrentTextEdit(new PretokenStringContainer((string.Empty + args.Character).Trim())); // Trim so that 'space' isn't inserted and can be used to insert a new box. _innerItemsSource.Insert(index, _currentTextEdit); // Need to wait for containerization _ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { var newContainer = ContainerFromIndex(index) as TokenizingTextBoxItem; // Should be our last text box newContainer.UseCharacterAsUser = true; // Make sure we trigger a refresh of suggested items. void WaitForLoad(object s, RoutedEventArgs eargs) { if (newContainer._autoSuggestTextBox != null) { newContainer._autoSuggestTextBox.SelectionStart = 1; // Set position to after our new character inserted newContainer._autoSuggestTextBox.Focus(FocusState.Keyboard); } newContainer.Loaded -= WaitForLoad; } newContainer.AutoSuggestTextBoxLoaded += WaitForLoad; }); } }); } else { // TODO: It looks like we're setting selection and focus together on items? Not sure if that's what we want... // If that's the case, don't think this code will ever be called? //// TODO: Behavior question: if no items selected (just focus) does it just go to our last active textbox? //// Community voted that typing in the end box made sense if (_innerItemsSource[_innerItemsSource.Count - 1] is ITokenStringContainer textToken) { var last = ContainerFromIndex(Items.Count - 1) as TokenizingTextBoxItem; // Should be our last text box var position = last._autoSuggestTextBox.SelectionStart; textToken.Text = last._autoSuggestTextBox.Text.Substring(0, position) + args.Character + last._autoSuggestTextBox.Text.Substring(position); last._autoSuggestTextBox.SelectionStart = position + 1; // Set position to after our new character inserted last._autoSuggestTextBox.Focus(FocusState.Keyboard); } } } }
private async void TokenizingTextBox_CharacterReceived(UIElement sender, CharacterReceivedRoutedEventArgs args) { var container = ContainerFromItem(_currentTextEdit) as TokenizingTextBoxItem; if (container != null && !(GetFocusedElement().Equals(container._autoSuggestTextBox) || char.IsControl(args.Character))) { if (SelectedItems.Count > 0) { var index = _innerItemsSource.IndexOf(SelectedItems.First()); await RemoveAllSelectedTokens(); // Wait for removal of old items var dispatcherQueue = DispatcherQueue.GetForCurrentThread(); _ = dispatcherQueue.EnqueueAsync( () => { // If we're before the last textbox and it's empty, redirect focus to that one instead if (index == _innerItemsSource.Count - 1 && string.IsNullOrWhiteSpace(_lastTextEdit.Text)) { var lastContainer = ContainerFromItem(_lastTextEdit) as TokenizingTextBoxItem; lastContainer.UseCharacterAsUser = true; // Make sure we trigger a refresh of suggested items. _lastTextEdit.Text = string.Empty + args.Character; UpdateCurrentTextEdit(_lastTextEdit); lastContainer._autoSuggestTextBox.SelectionStart = 1; // Set position to after our new character inserted lastContainer._autoSuggestTextBox.Focus(FocusState.Keyboard); } else { //// Otherwise, create a new textbox for this text. UpdateCurrentTextEdit(new PretokenStringContainer((string.Empty + args.Character).Trim())); // Trim so that 'space' isn't inserted and can be used to insert a new box. _innerItemsSource.Insert(index, _currentTextEdit); // Need to wait for containerization _ = dispatcherQueue.EnqueueAsync( () => { var newContainer = ContainerFromIndex(index) as TokenizingTextBoxItem; // Should be our last text box newContainer.UseCharacterAsUser = true; // Make sure we trigger a refresh of suggested items. void WaitForLoad(object s, RoutedEventArgs eargs) { if (newContainer._autoSuggestTextBox != null) { newContainer._autoSuggestTextBox.SelectionStart = 1; // Set position to after our new character inserted newContainer._autoSuggestTextBox.Focus(FocusState.Keyboard); } newContainer.Loaded -= WaitForLoad; } newContainer.AutoSuggestTextBoxLoaded += WaitForLoad; }, DispatcherQueuePriority.Normal); } }, DispatcherQueuePriority.Normal); } else { // If no items are selected, send input to the last active string container. // This code is only fires during an edgecase where an item is in the process of being deleted and the user inputs a character before the focus has been redirected to a string container. if (_innerItemsSource[_innerItemsSource.Count - 1] is ITokenStringContainer textToken) { var last = ContainerFromIndex(Items.Count - 1) as TokenizingTextBoxItem; // Should be our last text box var text = last._autoSuggestTextBox.Text; var selectionStart = last._autoSuggestTextBox.SelectionStart; var position = selectionStart > text.Length ? text.Length : selectionStart; textToken.Text = text.Substring(0, position) + args.Character + text.Substring(position); last._autoSuggestTextBox.SelectionStart = position + 1; // Set position to after our new character inserted last._autoSuggestTextBox.Focus(FocusState.Keyboard); } } } }
protected override void OnCharacterReceived(CharacterReceivedRoutedEventArgs e) { base.OnCharacterReceived(e); }
/// <summary> /// Gets the composed character associated with the UIElement.CharacterReceived event. /// </summary> /// <param name="e">The requested <see cref="CharacterReceivedRoutedEventArgs"/>.</param> /// <returns> /// The composed character associated with the UIElement.CharacterReceived event. /// </returns> public static char Character(this CharacterReceivedRoutedEventArgs e) => Resolver.Character(e);