示例#1
0
 private static void OnAccessKeyPressed(object sender, AccessKeyPressedEventArgs args)
 {
     if (!args.Handled && args.Scope == null && args.Target == null)
     {
         args.Target = (UIElement)sender;
     }
 }
示例#2
0
        // Token: 0x06004286 RID: 17030 RVA: 0x00130CBC File Offset: 0x0012EEBC
        private void UpdateIsDefaulted(IInputElement focus)
        {
            if (!this.IsDefault || focus == null || !base.IsEnabled)
            {
                base.SetValue(Button.IsDefaultedPropertyKey, BooleanBoxes.FalseBox);
                return;
            }
            DependencyObject dependencyObject = focus as DependencyObject;
            object           value            = BooleanBoxes.FalseBox;

            try
            {
                AccessKeyPressedEventArgs accessKeyPressedEventArgs = new AccessKeyPressedEventArgs();
                focus.RaiseEvent(accessKeyPressedEventArgs);
                object scope = accessKeyPressedEventArgs.Scope;
                accessKeyPressedEventArgs = new AccessKeyPressedEventArgs();
                base.RaiseEvent(accessKeyPressedEventArgs);
                object scope2 = accessKeyPressedEventArgs.Scope;
                if (scope2 == scope && (dependencyObject == null || !(bool)dependencyObject.GetValue(KeyboardNavigation.AcceptsReturnProperty)))
                {
                    value = BooleanBoxes.TrueBox;
                }
            }
            finally
            {
                base.SetValue(Button.IsDefaultedPropertyKey, value);
            }
        }
示例#3
0
 private static void OnAccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
 {
     if (!e.Handled && (e.Scope == null) && (e.Target == null))
     {
         e.Target = sender as DropDownButton;
     }
 }
示例#4
0
        private static void OnAccessKeyPressed(object sender, AccessKeyPressedEventArgs eventArgs)
        {
            if (eventArgs.Handled || eventArgs.Scope != null)
            {
                return;
            }

            var focusedElement = Keyboard.FocusedElement as FrameworkElement;

            if (focusedElement == null)
            {
                return;
            }

            // Do not accept access keys that originated outside of the DockTabPane.
            var dockTabPane = (DockTabPane)sender;

            if (!dockTabPane.IsVisualAncestorOf(focusedElement))
            {
                // Do not set eventArgs.Handled because this would break the chain.
                // --> Setting the scope skips the current target.
                eventArgs.Scope = dockTabPane;

                // See DigitalRune.Windows.AccessKeyScope for additional information!
            }
        }
示例#5
0
 private static void OnAccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
 {
     if ((!e.Handled && (e.Scope == null)) && (e.Target == null))
     {
         e.Target = (UIElement)sender;
     }
 }
 // Token: 0x06004E03 RID: 19971 RVA: 0x0015FA44 File Offset: 0x0015DC44
 private static void OnAccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
 {
     if (!e.Handled && e.Scope == null && e.Target == null)
     {
         e.Target = (sender as GroupBox);
     }
 }
示例#7
0
 private static void HandleScopedElementAccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
 {
     if (!Keyboard.IsKeyDown(System.Windows.Input.Key.LeftAlt) && !Keyboard.IsKeyDown(System.Windows.Input.Key.RightAlt) && GetIsAccessKeyScope((FrameworkElement)sender))
     {
         e.Scope   = sender;
         e.Handled = true;
     }
 }
 private static void OnAccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
 {
     if (e.Handled || e.Scope != null || e.Target != null)
     {
         return;
     }
     e.Target = (UIElement)sender;
 }
示例#9
0
 // Token: 0x060051CE RID: 20942 RVA: 0x0016E1DB File Offset: 0x0016C3DB
 private static void OnAccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
 {
     if (!Keyboard.IsKeyDown(Key.LeftAlt) && !Keyboard.IsKeyDown(Key.RightAlt))
     {
         e.Scope   = sender;
         e.Handled = true;
     }
 }
示例#10
0
 private static void HandleScopedElementAccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
 {
     if (!Keyboard.IsKeyDown(Key.LeftAlt) && !Keyboard.IsKeyDown(Key.RightAlt) && GetIsAccessKeyScope((DependencyObject)sender))
     {
         e.Scope   = sender;
         e.Handled = true;
     }
 }
示例#11
0
        // Token: 0x0600511C RID: 20764 RVA: 0x0016BEB0 File Offset: 0x0016A0B0
        private static void OnAccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
        {
            Label label = sender as Label;

            if (!e.Handled && e.Scope == null && (e.Target == null || e.Target == label))
            {
                e.Target = label.Target;
            }
        }
示例#12
0
        //-------------------------------------------------------------------
        //
        //  Private Methods
        //
        //-------------------------------------------------------------------

        #region Private Methods

        private static void OnAccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
        {
            // If ALT is down, then blend our scope into the one above. Maybe bad, but only if Menu is not top-level.
            if (!(Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt)))
            {
                e.Scope   = sender;
                e.Handled = true;
            }
        }
示例#13
0
        /// <summary>
        /// Fixes access key scoping bug within the WPF framework.
        /// </summary>
        /// <param name="sender">Potential target of the current access keys.</param>
        /// <param name="e">
        /// Info object for the current access keys and proxy to effect it's confirmation.
        /// </param>
        /// <remarks>
        /// The problem is that all access key presses are scoped to the active window,
        /// regardless of what properties, handlers, scope etc. you may have set. Targets
        /// are objects that have potential to be the target of the access keys in effect.
        ///
        /// If you happen to have a current object focused and you press the access keys
        /// of one of it's child's targets it will execute the child target. But, if you
        /// also have a ancestor target, the ancestor target will be executed instead.
        /// That goes against intuition and standard Windows behavior.
        /// The root of this logic (bug) is within the HwndSource.OnMnemonicCore method.
        /// If the scope is set to anything but the active window's HwndSource, the
        /// target will not be executed and the handler for the next target in the chain
        /// will be called.
        /// This handler gets called for every target within the scope, which because
        /// of the bug is always at the window level of the active window. If you set
        /// e.Handled to true, no further handlers in the chain will be executed. However
        /// because setting the scope to anything other than active window's HwndSource
        /// causes the target not to be acted on, we can use it to not act on the target
        /// while not canceling the chain either, thereby allowing us to skip to the next
        /// target's handler. Note that if a handler does act on the target it will
        /// inheritably break the chain because the menu will lose focus and the next
        /// handlers won't apply anymore; because a target has already been confirmed.
        /// We will use this knowledge to resolve the issue.
        /// We will set the scope to something other than the active window's HwndSource,
        /// if we find that the incorrect element is being targeted for the access keys
        /// (because the target is out of scope). This will cause the target to be
        /// skipped and the next target's handler will be called.
        /// If we detect the target is correct, we'll just leave everything alone so the
        /// target will be confirmed.
        ///
        /// NOTE: Do not call AccessKeyManager.IsKeyRegistered as it will cause a
        /// <see cref="T:System.StackOverflowException"/> to be thrown. The key is
        /// registered otherwise this handler wouldn't be called for it, therefore
        /// there is no need to call it.
        /// </remarks>
        private static void HandleAccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
        {
            var focusedElement = Keyboard.FocusedElement as FrameworkElement;

            if (focusedElement == null)
            {
                return; // No focused element.
            }
            if (Equals(sender, focusedElement))
            {
                return; // This is the correct target.
            }
            // Look through descendants tree to see if this target is a descendant of
            // the focused element. We will stop looking at either the end of the tree
            // or if a object with multiple children is encountered that this target
            // isn't a descendant of.

            // If no valid target is found, we'll set the scope to the sender which
            // results in skipping to the next target handler in the chain
            // (due to the bug).

            DependencyObject obj = focusedElement;

            while (obj != null)
            {
                int childCount = VisualTreeHelper.GetChildrenCount(obj);
                for (int i = 0; i < childCount; i++)
                {
                    if (VisualTreeHelper.GetChild(obj, i) == sender)
                    {
                        return; // Found correct target; let it execute.
                    }
                }

                if (childCount > 1)
                {
                    // This target isn't a direct descendant and there are multiple
                    // direct descendants; skip this target.
                    e.Scope = sender;
                    return;
                }

                if (childCount == 1)
                {
                    // This target isn't a direct descendant, but we'll keep looking
                    // down the descendants chain to see if it's a descendant of the
                    // direct descendant.
                    obj = VisualTreeHelper.GetChild(obj, 0);
                }
                else
                {
                    // End of the line; skip this target.
                    e.Scope = sender;
                    return;
                }
            }
        }
示例#14
0
文件: Label.cs 项目: ash2005/z
        private static void OnAccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
        {
            Label label = sender as Label;

            // ISSUE: if this is handled in Control then we need to check here as well
            if (!e.Handled && e.Scope == null && (e.Target == null || e.Target == label))
            {
                e.Target = label.Target;
            }
        }
示例#15
0
 private void OnAccessKeyPressed(object sender, AccessKeyPressedEventArgs args)
 {
     foreach (string accessKey in _renameAccessKeys)
     {
         if (string.Compare(accessKey, args.Key, StringComparison.OrdinalIgnoreCase) == 0)
         {
             args.Target  = this;
             args.Handled = true;
             return;
         }
     }
 }
示例#16
0
 /// <summary>
 /// Called when [access key pressed].
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="AccessKeyPressedEventArgs"/> instance containing the event data.</param>
 private static void OnAccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
 {
     if (!e.Handled && e.Scope == null && (e.Target == null))
     {
         //if alt key is not in use handle event to prevent behavior without alt key
         if ((Keyboard.Modifiers & ModifierKeys.Alt) != ModifierKeys.Alt)
         {
             e.Target  = null;
             e.Handled = true;
         }
     }
 }
示例#17
0
 // Token: 0x060056E0 RID: 22240 RVA: 0x001807C0 File Offset: 0x0017E9C0
 private static void OnAccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
 {
     if (!e.Handled && e.Scope == null)
     {
         TabItem tabItem = sender as TabItem;
         if (e.Target == null)
         {
             e.Target = tabItem;
             return;
         }
         if (!tabItem.IsSelected)
         {
             e.Scope   = tabItem;
             e.Handled = true;
         }
     }
 }
示例#18
0
        //--------------------------------------------------------------
        #region Methods
        //--------------------------------------------------------------

        private static void OnAccessKeyPressed(object sender, AccessKeyPressedEventArgs eventArgs)
        {
            // This code is borrowed from the WPF TabItem.
            if (!eventArgs.Handled && eventArgs.Scope == null)
            {
                var dockTabItem = (DockTabItem)sender;
                if (eventArgs.Target == null)
                {
                    eventArgs.Target = dockTabItem;
                }
                else if (!dockTabItem.IsSelected)    // If DockTabItem is not active it is a scope for its content elements.
                {
                    eventArgs.Scope   = dockTabItem;
                    eventArgs.Handled = true;
                }
            }
        }
示例#19
0
        //-------------------------------------------------------------------
        //
        //  Private Methods
        //
        //-------------------------------------------------------------------

        #region Private Methods

        private static void OnAccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
        {
            if (!e.Handled && e.Scope == null)
            {
                TabItem tabItem = sender as TabItem;

                if (e.Target == null)
                {
                    e.Target = tabItem;
                }
                else if (!tabItem.IsSelected) // If TabItem is not active it is a scope for its content elements
                {
                    e.Scope   = tabItem;
                    e.Handled = true;
                }
            }
        }
示例#20
0
        private static void OnAccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
        {
            if (Keyboard.IsKeyDown(Key.Enter) || Keyboard.IsKeyDown(Key.Escape))
            {
                return;
            }

            if (!e.Handled && e.Scope == null && (e.Target == null)) //|| e.Target == label
            {
                // If Alt key is not pressed - handle the event
                if ((Keyboard.Modifiers & ModifierKeys.Alt) != ModifierKeys.Alt)
                {
                    e.Target  = null;
                    e.Handled = true;
                }
            }
        }
示例#21
0
        /// <summary>
        /// This is overridden to pass hot keys on to the contained user control.
        /// </summary>
        /// <param name="m">The message to pre-process</param>
        /// <returns>True if the message was handled, false if not</returns>
        /// <remarks>When a WPF user control is hosted in a docked tool window, the hot keys no longer work.
        /// This works around the problem by manually seeing if the control makes use of the hot key, and if
        /// it does, processing it here.</remarks>
        protected override bool PreProcessMessage(ref System.Windows.Forms.Message m)
        {
            if (m.Msg == 0x0100 /* WM_KEYDOWN */)
            {
                System.Windows.Forms.Keys keyCode = (System.Windows.Forms.Keys)m.WParam &
                                                    System.Windows.Forms.Keys.KeyCode;

                if (keyCode == System.Windows.Forms.Keys.F1)
                {
                    ApplicationCommands.Help.Execute(null, (UserControl)base.Content);
                    return(true);
                }
            }

            if (m.Msg == 0x0104 /* WM_SYSKEYDOWN */)
            {
                if (Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt))
                {
                    // Cache a copy of the scope on first use
                    if (scope == null && base.Content != null)
                    {
                        // Get the scope for handling hot keys.  The key used here doesn't matter.  We're just
                        // getting the scope to use.
                        AccessKeyPressedEventArgs e = new AccessKeyPressedEventArgs("X");

                        ((UserControl)base.Content).RaiseEvent(e);
                        scope = e.Scope;
                    }

                    string key = ((char)m.WParam).ToString();

                    // See if the hot key is registered for the control.  If so, handle it.  Ignore anything
                    // that isn't 'A' to 'Z'
                    if (scope != null && key[0] >= 'A' && key[0] <= 'Z' && AccessKeyManager.IsKeyRegistered(scope, key))
                    {
                        AccessKeyManager.ProcessKey(scope, key, false);
                        return(true);
                    }
                }
            }

            return(base.PreProcessMessage(ref m));
        }
示例#22
0
        private void UpdateIsDefaulted(IInputElement focus)
        {
            // If it's not a default button, or nothing is focused, or it's disabled then it's not defaulted.
            if (!IsDefault || focus == null || !IsEnabled)
            {
                SetValue(IsDefaultedPropertyKey, BooleanBoxes.FalseBox);
                return;
            }

            DependencyObject focusDO = focus as DependencyObject;
            object           thisScope, focusScope;

            // If the focused thing is not in this scope then IsDefaulted = false
            AccessKeyPressedEventArgs e;

            object isDefaulted = BooleanBoxes.FalseBox;

            try
            {
                // Step 1: Determine the AccessKey scope from currently focused element
                e = new AccessKeyPressedEventArgs();
                focus.RaiseEvent(e);
                focusScope = e.Scope;

                // Step 2: Determine the AccessKey scope from this button
                e = new AccessKeyPressedEventArgs();
                this.RaiseEvent(e);
                thisScope = e.Scope;

                // Step 3: Compare scopes
                if (thisScope == focusScope && (focusDO == null || (bool)focusDO.GetValue(KeyboardNavigation.AcceptsReturnProperty) == false))
                {
                    isDefaulted = BooleanBoxes.TrueBox;
                }
            }
            finally
            {
                SetValue(IsDefaultedPropertyKey, isDefaulted);
            }
        }
示例#23
0
 private static void OnAccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
 {
     e.Scope   = sender;
     e.Handled = true;
 }
示例#24
0
 private void Content_AccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
 {
     e.Scope   = sender;
     e.Handled = true;
 }
 private void webView_AccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
 {
     Debug.WriteLine("AccessKeyPressed: " + e.Key.ToString());
 }
 private void cbxLoaiSP_AccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
 {
 }
示例#27
0
 void GridAccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
 {
     throw new NotImplementedException();
 }
示例#28
0
 private void Expander_AccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
 {
 }
示例#29
0
 private void StackPanel_AccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
 {
 }
示例#30
0
 private void MenuExit_AccessKeyPressed(object sender, AccessKeyPressedEventArgs e)
 {
     this.Close();
     System.Windows.Application.Current.Shutdown();
     System.Windows.MessageBox.Show("Exit Menu clicked.\r\nNot yet implemented. QA, report this.", Title, MessageBoxButton.OK, MessageBoxImage.Error);
 }