private void txtMyProfile_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { if (txtMyProfile.Text == DefaultTextMySteamProfile) { txtMyProfile.Clear(); } }
private void TextBoxGotKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { TextBox box = (TextBox)sender; box.SelectAll(); box.Focus(); }
// // FUNCTION : nameBox_GotKeyboardFocus // // DESCRIPTION : Handles focus of the nameBox. When it is focused (ususally through a click) the default // text will change to blank. // // PARAMETERS : Object sender - contains a reference to the control/object that raised the event // // RoutedEventArgs e - Contains state information and event data associated with a routed event. // (https://docs.microsoft.com/en-us/dotnet/api/system.windows.routedeventargs?view=netframework-4.7.2) // // RETURNS : None // private void nameBox_GotKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { if (nameBox.Text == "Enter a username") { nameBox.Text = string.Empty; } }
private void tbName_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { if (tbName.Text == "Имя") { tbName.Text = ""; } }
/// <summary> /// Handles TextBox.GotKeyboardFocus event. /// </summary> protected override void OnGotKeyboardFocus(System.Windows.Input.KeyboardFocusChangedEventArgs e) { if (SelectAllOnFocus) { // Select all of the text in the control. this.SelectAll(); // Allow the TextBox.GotMouseCapture custom code to execute. CancelGotMouseCapture = true; // Invoke the OnFocusComplete method. The method should run as the last step // of the textbox focusing logic. this.Dispatcher.BeginInvoke( OnFocusCompleteInvoker, System.Windows.Threading.DispatcherPriority.Input, this); } else { // Select feature is disabled. Prevent the TextBox.GotMouseCapture custom code from executing. if (CancelGotMouseCapture) { CancelGotMouseCapture = false; } } base.OnGotKeyboardFocus(e); }
private void MaskedTextBox_PreviewLostKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { int?hours; int?minutes; MaskedTextBox textbox = (sender as MaskedTextBox); if (!ParseTimeSpanMask(textbox.Text, textbox.PromptChar, out hours, out minutes)) { return; } if (hours.HasValue && hours.Value < 10) { textbox.Text = hours.Value.ToString().PadLeft(2, '0') + textbox.Text.Substring(2); } if (minutes.HasValue && minutes.Value < 10) { textbox.Text = textbox.Text.Substring(0, 3) + minutes.Value.ToString().PadLeft(2, '0'); } if (hours.HasValue || minutes.HasValue) { textbox.Text = textbox.Text.Replace(textbox.PromptChar, '0'); } }
// // FUNCTION : connectBox_GotKeyboardFocus // // DESCRIPTION : Handles focus of the connectBox. When it is focused (ususally through a click) the default // text will change to blank. // // PARAMETERS : Object sender - contains a reference to the control/object that raised the event // // RoutedEventArgs e - Contains state information and event data associated with a routed event. // (https://docs.microsoft.com/en-us/dotnet/api/system.windows.routedeventargs?view=netframework-4.7.2) // // RETURNS : None // private void connectBox_GotKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { if (connectBox.Text == "Enter an IP") { connectBox.Text = string.Empty; } }
private void TextBox_GotKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { if (sender is TextBox txtBox && txtBox.Text == "Вопрос") { txtBox.Text = string.Empty; } }
protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e) { if (this.IsKeyboardFocusWithin) { this.lastElementWithFocus = e.NewFocus as FrameworkElement; } }
protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e) { if (Model != null) Model.IsActive = true; base.OnGotKeyboardFocus(e); }
private void ValidDateTextBox_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { if (HasError) { e.Handled = true; } }
private void OnLostKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { if (string.IsNullOrEmpty(filterBox.Text)) { textBlock.Visibility = Visibility.Visible; } }
protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e) { if ((e.OldFocus is DataGridCell)) return; Keyboard.Focus(_lastDataGridFocus); if (SelectedIndex == -1 && Items.Count > 0) SelectedIndex = 0; e.Handled = true; }
private void Window_GotKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { if (ganttControl1.IsLoaded) { RefreshEvents(); } }
private void projectTextBox_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { if (!string.IsNullOrEmpty(this.selectedProject.ProjectLabel)) { this.selectProject(this.selectedProject); } }
} // End BtnConfirm_Click() private void TxtQuantityMoving_GotKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { if (e.KeyboardDevice.IsKeyDown(Key.Tab)) { ((TextBox)sender).SelectAll(); } }
protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e) { if (SelectAllOnGotFocus) SelectAll(); base.OnGotKeyboardFocus(e); }
private void txtMess_LostKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { if (txtMess.Text == "") { txtMess.Text = "Type your message here..."; } }
private void textBox_LostKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { EnableEdit = false; BindingExpression be = textBox_float.GetBindingExpression(TextBox.TextProperty); be.UpdateSource(); }
protected override void OnGotKeyboardFocus(System.Windows.Input.KeyboardFocusChangedEventArgs e) { base.OnGotKeyboardFocus(e); BorderThickness = new Thickness(1); Margin = new Thickness(0, 0, 8, 0); }
protected override void OnPreviewLostKeyboardFocus(System.Windows.Input.KeyboardFocusChangedEventArgs e) { BindingExpression be = GetBindingExpression(TextBox.TextProperty); be.UpdateSource(); base.OnPreviewLostKeyboardFocus(e); }
protected override void OnLostKeyboardFocus(KeyboardFocusChangedEventArgs e) { txtReadOnly.Visibility = Visibility.Visible; txtEdit.Visibility = Visibility.Collapsed; Text = EditedText; base.OnLostKeyboardFocus(e); }
private void Window_LostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { if (!closing) { this.Close(); } }
private void OnGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { if (e.OldFocus is MenuItem) { return; } SelectTextInTextBox(sender); }
protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e) { base.OnGotKeyboardFocus(e); if (this.SelectedIndex == -1) { this.SelectedIndex = 0; } }
protected override void OnLostKeyboardFocus(KeyboardFocusChangedEventArgs e) { base.OnLostKeyboardFocus(e); if (IsKeyboardFocusWithin) return; if (IsOpen) Child.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next)); }
private void Editor_LostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { if (_drawFocus) { _drawFocus = false; InvalidateVisual(); } }
private void Editor_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { if (!_drawFocus) { _drawFocus = true; InvalidateVisual(); } }
protected override void OnPreviewGotKeyboardFocus(KeyboardFocusChangedEventArgs e) { if (!this.IsRootDesigner) { this.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(this.BringToFront)); } base.OnPreviewGotKeyboardFocus(e); }
/// Forward focus to TextArea. /// <inheritdoc/> protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e) { base.OnGotKeyboardFocus(e); if (e.NewFocus == this) { Keyboard.Focus(this.TextArea); e.Handled = true; } }
private void InputTextBox_LostKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { if (InputTextBox.Text == "") { InputTextBox.Text = "搜索栏"; InputTextBox.Opacity = 0.8; } }
void OnKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { if (e.NewFocus == this) { terminalControl.Focus(); Keyboard.Focus(terminalControl); } }
private static void TextboxOnGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs keyboardFocusChangedEventArgs) { var textbox = sender as TextBox; if (textbox == null) return; textbox.CaretIndex = textbox.Text.Length; textbox.ScrollToEnd(); }
private void OnLostKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { if (sender is TextBox textBox) { var command = textBox.Tag as ICommand; command?.Execute(e); } }
void TextAreaGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { if (this.textArea == null) return; if (e.OriginalSource != this.textArea) return; CreateContext(); }
private void PasswordBox_LostKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { if (passwordBox.Password.Equals("")) { passwordBox.Password = "******"; passwordBox.Foreground = Brushes.DarkGray; } }
private void LoginBox_GotKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { if (textBoxLogin.Text.Equals("Username")) { textBoxLogin.Text = ""; textBoxLogin.Foreground = Brushes.Black; } }
private static void OnKeyboardFocusSelectText(object sender, KeyboardFocusChangedEventArgs e) { TextBox textBox = e.OriginalSource as TextBox; if (textBox != null) { textBox.SelectAll(); } }
/// Forward focus to TextArea. /// <inheritdoc/> protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e) { base.OnGotKeyboardFocus(e); if (!this.TextArea.IsKeyboardFocusWithin) { Keyboard.Focus(this.TextArea); e.Handled = true; } }
//void UpdateLogicalParent() //{ // var parentPaneControl = this.FindVisualAncestor<LayoutDocumentPaneControl>(); // if (parentPaneControl == null) // throw new InvalidOperationException(); // try // { // if (Model != null && // Model.Content != null && // Model.Content is UIElement) // { // var oldLogicalParentPaneControl = LogicalTreeHelper.GetParent(Model.Content as UIElement) // as ILogicalChildrenContainer; // if (oldLogicalParentPaneControl == parentPaneControl) // return; // if (oldLogicalParentPaneControl != null) // oldLogicalParentPaneControl.InternalRemoveLogicalChild(Model.Content); // } // if (Model != null && // parentPaneControl != null && // Model.Content != null && // Model.Content is UIElement) // { // ((ILogicalChildrenContainer)parentPaneControl).InternalAddLogicalChild(Model.Content); // //BindingHelper.RebindInactiveBindings(Model.Content as UIElement); // } // } // finally // { // if (Model != null && Model.Content is DependencyObject) // BindingHelper.RebindInactiveBindings(Model.Content as DependencyObject); // } //} #endregion protected override void OnPreviewGotKeyboardFocus(System.Windows.Input.KeyboardFocusChangedEventArgs e) { if (Model != null) { Model.IsActive = true; } base.OnPreviewGotKeyboardFocus(e); }
private void OnListBoxPreviewGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { ListBoxItem item = VisualTreeUtils.FindVisualAncestor<ListBoxItem>(e.OriginalSource as DependencyObject); if (item != null) { this.SelectedListItem = item.Content as ExpandableItemWrapper; } }
/// <summary> /// Handles the keyboard focus event /// </summary> private void textBox_GotKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { //prepare popup with values. PreparePopup(); //attach the events sourceTextBox.AddHandler(FrameworkElement.PreviewKeyDownEvent, new KeyEventHandler(textBox_PreviewKeyDown), true); sourceTextBox.AddHandler(TextBox.TextChangedEvent, new TextChangedEventHandler(textBox_TextChanged), true); }
protected override void OnGotKeyboardFocus(System.Windows.Input.KeyboardFocusChangedEventArgs e) { base.OnGotKeyboardFocus(e); System.Diagnostics.Trace.WriteLine(string.Format("OnGotKeyboardFocus({0}, {1})", e.Source, e.NewFocus)); //if (_model.SelectedContent != null) // _model.SelectedContent.IsActive = true; }
private void TextBox_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { var textbox = sender as TextBox; if (textbox != null) { textbox.SelectAll(); } }
protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e) { if (!(Mouse.LeftButton == MouseButtonState.Pressed && this.IsMouseOver)) { this.onFocusedByTab(); } base.OnGotKeyboardFocus(e); }
protected override void OnLostKeyboardFocus(KeyboardFocusChangedEventArgs e) { if (this.SelectAllOnKeyboardFocus) { this.SelectionLength = 0; } base.OnLostKeyboardFocus(e); }
protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e) { base.OnGotKeyboardFocus(e); var result = OnScreenKeyboardService.GetIntValue(); if (result != null) { Text = result.Value.ToString(CultureInfo.CurrentCulture); } }
protected override void OnPreviewGotKeyboardFocus( KeyboardFocusChangedEventArgs e ) { base.OnPreviewGotKeyboardFocus( e ); if( this.Child != null ) { CellEditor.SetHasError( ( DependencyObject )this.Child, false ); } }
protected override void OnLostKeyboardFocus(KeyboardFocusChangedEventArgs e) { // We could have lost focus because we're already closing, make sure this doesn't call close twice if (!_closing) { Close(); } base.OnLostKeyboardFocus(e); }
private void dp_endedatum_GotKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { DatePickerTextBox dptb_endedatum = (DatePickerTextBox)dp_endedatum.Template.FindName("PART_TextBox", dp_endedatum); if (dptb_endedatum != null) { dptb_endedatum.SelectAll(); } }
// Behaviour: Highlight the border and make the text caret appear whenever the control gets the keyboard focus private void ContentControl_GotKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { this.ContentControl.BorderThickness = new Thickness(Constant.Control.BorderThicknessHighlight); this.ContentControl.BorderBrush = Constant.Control.BorderColorHighlight; if (this.ContentControl.Template.FindName("PART_TextBox", this.ContentControl) is Xceed.Wpf.Toolkit.WatermarkTextBox textBox) { textBox.IsReadOnlyCaretVisible = true; } }
protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e) { base.OnGotKeyboardFocus(e); if (SelectAllOnGotFocus) SelectAll(); else SelectionLength = 0; }
private void InputTextBox_GotKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { if (InputTextBox.Text == "搜索栏") { InputTextBox.Text = ""; } InputTextBox.SelectAll(); InputTextBox.Opacity = 1.0; }
protected override void OnLostKeyboardFocus(System.Windows.Input.KeyboardFocusChangedEventArgs e) { base.OnLostKeyboardFocus(e); if (!IsMouseOver) { BorderThickness = new Thickness(0); Margin = new Thickness(2, 2, 10, 2); } }
void AssociatedObject_GotKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { Debug.WriteLine("FocusBorderAdornerBehavior - AssociatedObject_GotKeyboardFocus " + AssociatedObject); CreateAdorner(); if (_adorner != null) { _adorner.Visibility = Visibility.Visible; } }
private void TextBox_LostKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { if (textbox != null && suggestionsList != null) { if (suggestionsList.IsKeyboardFocusWithin) { return; } } ClearSuggestions(); }
private void textBox_LostKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { // 按完回车后这里会再调用一次,去掉重复调用 //EnableEdit = false; //BindingExpression be = textBox.GetBindingExpression(TextBox.TextProperty); //if(be != null) //{ // be.UpdateSource(); // OnValueManualChanged?.Invoke(); //} }
/// <summary> /// Update the text when focus is lost. /// </summary> /// <param name="e">The event arguments.</param> protected override void OnLostKeyboardFocus(System.Windows.Input.KeyboardFocusChangedEventArgs e) { BindingExpression bindingExpression = this.GetBindingExpression(MaskedTextBox.TextProperty); base.OnLostKeyboardFocus(e); // For some reason, the selection isn't getting cleared when we lose keyboard focus, so we force it here. this.SelectionLength = 0; // Make sure the display looks reflects the underlying values. bindingExpression.UpdateTarget(); }
protected override void OnGotKeyboardFocus(System.Windows.Input.KeyboardFocusChangedEventArgs e) { if (Text.Contains(NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)) { CaretIndex = Text.IndexOf(NumberFormatInfo.CurrentInfo.NumberDecimalSeparator); } else { CaretIndex = Text.Length; } base.OnGotKeyboardFocus(e); }
/// <summary>フォーカスロス</summary> /// <param name="sender">源</param> /// <param name="e">イベント</param> private void Window_LostKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e) { if (_needFocus) { this.Focusable = true; Keyboard.Focus(this); _needFocus = false; } else { this.Topmost = false; } }