Example #1
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            bool markHandled = ValueEditorUtils.GetHandlesCommitKeys(this);

            if (e.Key == Key.Return || e.Key == Key.Enter)
            {
                LostFocusAction savedAction = this.lostFocusAction;
                this.lostFocusAction = LostFocusAction.None;
                if (savedAction == LostFocusAction.Commit)
                {
                    this.CommitChange();
                }

                if ((e.KeyboardDevice.Modifiers & ModifierKeys.Shift) == 0)
                {
                    this.OnFinishEditing();
                }

                e.Handled |= markHandled;
            }
            else if (e.Key == Key.Escape && this.IsEditing)
            {
                LostFocusAction savedAction = this.lostFocusAction;
                this.lostFocusAction = LostFocusAction.None;
                if (savedAction != LostFocusAction.None)
                {
                    this.CancelChange();
                }

                this.OnFinishEditing();

                e.Handled |= markHandled;
            }
            base.OnKeyDown(e);
        }
Example #2
0
        protected override void OnTextChanged(TextChangedEventArgs e)
        {
            base.OnTextChanged(e);

            if (this.ignoreTextChanges)
            {
                return;
            }

            if (this.IsEditing)
            {
                // If we get any text change default to commit if focus goes away
                this.lostFocusAction = LostFocusAction.Commit;
            }
        }
Example #3
0
        private void InternalLostFocus()
        {
            LostFocusAction savedLostFocusAction = this.lostFocusAction;

            // Set this to none here so that we will not commit twice when re-entrant (preview lost keyboard focus, then
            // lost keyboard focus in the same callstack)
            this.lostFocusAction = LostFocusAction.None;
            if (savedLostFocusAction == LostFocusAction.Commit)
            {
                this.CommitChange();
            }
            else if (savedLostFocusAction == LostFocusAction.Cancel)
            {
                this.CancelChange();
            }
        }
        protected override void OnKeyDown(KeyEventArgs e)
        {
            bool markHandled = ValueEditorUtils.GetHandlesCommitKeys(this);
            if (e.Key == Key.Return || e.Key == Key.Enter)
            {
                LostFocusAction savedAction = this.lostFocusAction;
                this.lostFocusAction = LostFocusAction.None;
                if (savedAction == LostFocusAction.Commit)
                {
                    this.CommitChange();
                }

                if ((e.KeyboardDevice.Modifiers & ModifierKeys.Shift) == 0)
                {
                    this.OnFinishEditing();
                }

                e.Handled |= markHandled;
            }
            else if (e.Key == Key.Escape && this.IsEditing)
            {
                LostFocusAction savedAction = this.lostFocusAction;
                this.lostFocusAction = LostFocusAction.None;
                if (savedAction != LostFocusAction.None)
                {
                    this.CancelChange();
                }

                this.OnFinishEditing();

                e.Handled |= markHandled;
            }
            base.OnKeyDown(e);
        }
        protected override void OnTextChanged(TextChangedEventArgs e)
        {
            base.OnTextChanged(e);

            if (this.ignoreTextChanges)
            {
                return;
            }

            if (this.IsEditing)
            {
                // If we get any text change default to commit if focus goes away
                this.lostFocusAction = LostFocusAction.Commit;
            }
        }
 private void InternalLostFocus()
 {
     LostFocusAction savedLostFocusAction = this.lostFocusAction;
     // Set this to none here so that we will not commit twice when re-entrant (preview lost keyboard focus, then
     // lost keyboard focus in the same callstack)
     this.lostFocusAction = LostFocusAction.None;
     if (savedLostFocusAction == LostFocusAction.Commit)
     {
         this.CommitChange();
     }
     else if (savedLostFocusAction == LostFocusAction.Cancel)
     {
         this.CancelChange();
     }
 }
 public void AttributeName_LostFocus()
 {
     LostFocusAction?.Invoke(this);
     isEdited = false;
 }
Example #8
0
        private void CommitChange()
        {
            ValueEditorUtils.ExecuteCommand(this.BeginCommand, this, null);

            if (this.UpdateValueFromInternalValues())
            {
                // We need to update both the binding on the value property and the valueindex property
                // so that the value does not bounce around when we commit.
                ValueEditorUtils.UpdateBinding(this, ChoiceEditor.ValueProperty, UpdateBindingType.Source);
                ValueEditorUtils.UpdateBinding(this, ChoiceEditor.ValueIndexProperty, UpdateBindingType.Source);
                ValueEditorUtils.ExecuteCommand(this.CommitCommand, this, null);
                ValueEditorUtils.UpdateBinding(this, ChoiceEditor.ValueProperty, UpdateBindingType.Target);
                ValueEditorUtils.UpdateBinding(this, ChoiceEditor.ValueIndexProperty, UpdateBindingType.Target);
            }
            else
            {
                this.CancelStartedChange();
            }

            this.lostFocusAction = LostFocusAction.None;
        }
Example #9
0
        private void HandleLostFocus()
        {
            if (this.isTextEditing)
            {
                LostFocusAction oldLostFocusAction = this.lostFocusAction;
                this.lostFocusAction = LostFocusAction.None;
                this.isTextEditing = false;


                if (oldLostFocusAction == LostFocusAction.Commit)
                {
                    this.CommitChange();
                }
                else if (oldLostFocusAction == LostFocusAction.Cancel)
                {
                    this.CancelChange();
                }

                this.CoerceValue(ChoiceEditor.ShowFullControlProperty);
            }
        }
Example #10
0
        // ###################################################
        // CIDER-SPECIFIC CHANGE IN NEED OF PORTING - BEGIN
        // ###################################################
        // CIDER needs to override the Keydown behavior : 
        //   
        //          * The problem here is just a difference in expectation for control behavior 
        //          * between the two products (CIDER AND BLEND). The fix is entirely in OnPreviewKeyDown 
        //          * a.    Remove the condition that we handle navigation keys only when the popup is open
        //          * b.    Add logic that forces a commit when a navigation happens (you could optionally only do the commit when the popup is closed, but I�m not sure what the desired behavior is here). You may or may not want to limit this behavior to editable ChoiceEditors as well.//          

        protected override void OnPreviewKeyDown(KeyEventArgs e)
        {
            bool commitChange = false;
            bool finishEditing = false;

            bool markHandled = ValueEditorUtils.GetHandlesCommitKeys(this);

            if (e.Key == Key.Return || e.Key == Key.Enter)
            {
                e.Handled |= markHandled;

                commitChange = true;

                finishEditing = (e.KeyboardDevice.Modifiers & ModifierKeys.Shift) == 0;
                //Hide dropdown on excape key
                HideDropDown();
            }
            else if (e.Key == Key.Escape)
            {
                e.Handled |= markHandled;

                LostFocusAction savedAction = this.lostFocusAction;
                this.lostFocusAction = LostFocusAction.None;
                if (savedAction != LostFocusAction.None)
                {
                    this.CancelChange();
                }

                //Hide dropdown on excape key
                HideDropDown();
                this.OnFinishEditing();
            }
            // Only pay attention to navigation keys if we are selecting a value from the popup
            if (this.CollectionView != null && !this.CollectionView.IsEmpty)
            {
                bool navigated = false;
                if (e.Key == Key.Up || (!this.IsEditable && e.Key == Key.Left))
                {
                    this.SelectPreviousValue();
                    navigated = true;
                }
                else if (e.Key == Key.Down || (!this.IsEditable && e.Key == Key.Right))
                {
                    this.SelectNextValue();
                    navigated = true;
                }
                else if (!this.IsEditable && e.Key == Key.Home)
                {
                    this.ValueIndex = 0;
                    navigated = true;
                }
                else if (!this.IsEditable && e.Key == Key.End)
                {
                    this.ValueIndex = this.CollectionView.Count - 1;
                    navigated = true;
                }

                if (navigated)
                {
                    this.lostFocusAction = LostFocusAction.Commit;
                    e.Handled = true;
                    ComboBox comboBox = this.Template.FindName("_comboChoiceEditor", this) as ComboBox;
                    if (!comboBox.IsDropDownOpen)
                    {
                        commitChange = true;
                    }
                }
            }

            if (commitChange)
            {
                LostFocusAction savedAction = this.lostFocusAction;
                this.lostFocusAction = LostFocusAction.None;
                if (savedAction == LostFocusAction.Commit)
                {
                    this.CommitChange();
                }
            }
            if (finishEditing)
            {
                this.OnFinishEditing();
            }
            base.OnPreviewKeyDown(e);
        }