SelectNextControl() public method

public SelectNextControl ( Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap ) : bool
ctl Control
forward bool
tabStopOnly bool
nested bool
wrap bool
return bool
Example #1
0
 //  CSS added for keyboard interop
 protected override bool ProcessDialogKey(Keys keyData)
 {
     _focusTarget.Enabled = false;
     try
     {
         if ((keyData & (Keys.Alt | Keys.Control)) == Keys.None)
         {
             Keys keyCode = (Keys)keyData & Keys.KeyCode;
             if (keyCode == Keys.Tab || keyCode == Keys.Left ||
                 keyCode == Keys.Right || keyCode == Keys.Up ||
                 keyCode == Keys.Down)
             {
                 if (this.Focused || this.ContainsFocus)
                 {
                     // CSS:  In WF apps, by default, arrow keys always wrap within a container
                     // However, we don't want them to wrap in the Adapter, which always has only
                     // one immediate child
                     if ((keyCode == Keys.Left || keyCode == Keys.Right || keyCode == Keys.Down || keyCode == Keys.Up) &&
                         (this.ActiveControl != null && this.ActiveControl.Parent == this))
                     {
                         SWF.Control c = this.ActiveControl.Parent;
                         return(c.SelectNextControl(this.ActiveControl, keyCode == Keys.Right || keyCode == Keys.Down, false, false, false));
                     }
                     else
                     {
                         return(base.ProcessDialogKey(keyData));
                     }
                 }
             }
         }
         return(false);
     }
     finally { _focusTarget.Enabled = true; }
 }
Example #2
0
        // Process a key mnemonic.  For labels, we pass the selection
        // focus onto the control that follows the label.
        protected override bool ProcessMnemonic(char charCode)
        {
            if (useMnemonic && IsMnemonic(charCode, Text))
            {
                Control parent    = Parent;
                Control hierarchy = parent;
                while (hierarchy != null)
                {
                    if (!hierarchy.Enabled || !hierarchy.Visible)
                    {
                        return(base.ProcessMnemonic(charCode));
                    }
                    hierarchy = hierarchy.Parent;
                }

                if (parent != null)
                {
                    if (parent.SelectNextControl(this, true, false, true, false) && !parent.ContainsFocus)
                    {
                        parent.Focus();
                    }
                    return(true);
                }
            }
            return(base.ProcessMnemonic(charCode));
        }
Example #3
0
 /// <include file='doc\Label.uex' path='docs/doc[@for="Label.ProcessMnemonic"]/*' />
 /// <internalonly/>
 /// <devdoc>
 ///    <para>
 ///       Overrides Control. This is called when the user has pressed an Alt-CHAR
 ///       key combination and determines if that combination is an interesting
 ///       mnemonic for this control.
 ///    </para>
 /// </devdoc>
 protected override bool ProcessMnemonic(char charCode)
 {
     if (UseMnemonic && IsMnemonic(charCode, Text) && CanProcessMnemonic())
     {
         Control parent = ParentInternal;
         if (parent != null)
         {
             IntSecurity.ModifyFocus.Assert();
             try {
                 if (parent.SelectNextControl(this, true, false, true, false))
                 {
                     if (!parent.ContainsFocus)
                     {
                         parent.Focus();
                     }
                 }
             }
             finally {
                 System.Security.CodeAccessPermission.RevertAssert();
             }
         }
         return(true);
     }
     return(false);
 }
Example #4
0
        protected internal override bool ProcessMnemonic(char charCode)
        {
            if ((!this.UseMnemonic || !Control.IsMnemonic(charCode, this.Text)) || !this.CanProcessMnemonic())
            {
                return(false);
            }
            Control parentInternal = this.ParentInternal;

            if (parentInternal != null)
            {
                System.Windows.Forms.IntSecurity.ModifyFocus.Assert();
                try
                {
                    if (parentInternal.SelectNextControl(this, true, false, true, false) && !parentInternal.ContainsFocus)
                    {
                        parentInternal.Focus();
                    }
                }
                finally
                {
                    CodeAccessPermission.RevertAssert();
                }
            }
            return(true);
        }
        /// <devdoc>
        ///     Process an arrowKey press by selecting the next control in the group
        ///     that the activeControl belongs to.
        /// </devdoc>
        /// <internalonly/>
        private bool ProcessArrowKey(bool forward)
        {
            Control group = this;

            if (activeControl != null)
            {
                group = activeControl.ParentInternal;
            }
            return(group.SelectNextControl(activeControl, forward, false, false, true));
        }
 // This will select the correct active control in the containerControl (if the passed in control is a containerControl)
 private static void SelectNextActiveControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap)
 {
     ContainerControl container = ctl as ContainerControl;
     if (container != null)
     {
         bool correctParentActiveControl = true;
         if (container.ParentInternal != null)
         {
             IContainerControl c = container.ParentInternal.GetContainerControlInternal();
             if (c != null)
             {
                 c.ActiveControl = container;
                 correctParentActiveControl = (c.ActiveControl == container);
             }
         }
         if (correctParentActiveControl)
         {
             ctl.SelectNextControl(null, forward, tabStopOnly, nested, wrap);
         }
     }
     else
     {
         ctl.Select();
     }
 }
		public static object CallControlSelectNextControl(Control c, object[] obj)
		{
			return c.SelectNextControl((Control)obj[0], (bool)obj[1], (bool)obj[2],
				(bool)obj[3], (bool)obj[4]);
		}
Example #8
0
 public static object CallControlSelectNextControl(Control c, object[] obj)
 {
     return(c.SelectNextControl((Control)obj[0], (bool)obj[1], (bool)obj[2],
                                (bool)obj[3], (bool)obj[4]));
 }
Example #9
0
 public static void textBox_KeyUp(Control control, object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         control.SelectNextControl(control, true, true, false, true);
     }
 }
Example #10
0
		public void TestPublicMethods ()
		{
			// Public Methods that force Handle creation:
			// - CreateControl ()
			// - CreateGraphics ()
			// - GetChildAtPoint ()
			// - Invoke, BeginInvoke throws InvalidOperationException if Handle has not been created
			// - PointToClient ()
			// - PointToScreen ()
			// - RectangleToClient ()
			// - RectangleToScreen ()
			Control c = new Control ();
			
			c.BringToFront ();
			Assert.IsFalse (c.IsHandleCreated, "A1");
			c.Contains (new Control ());
			Assert.IsFalse (c.IsHandleCreated, "A2");
			c.CreateControl ();
			Assert.IsTrue (c.IsHandleCreated, "A3");
			c = new Control ();
			Graphics g = c.CreateGraphics ();
			g.Dispose ();
			Assert.IsTrue (c.IsHandleCreated, "A4");
			c = new Control ();
			c.Dispose ();
			Assert.IsFalse (c.IsHandleCreated, "A5");
			c = new Control ();
			//DragDropEffects d = c.DoDragDrop ("yo", DragDropEffects.None);
			//Assert.IsFalse (c.IsHandleCreated, "A6");
			//Assert.AreEqual (DragDropEffects.None, d, "A6b");
			//Bitmap b = new Bitmap (100, 100);
			//c.DrawToBitmap (b, new Rectangle (0, 0, 100, 100));
			//Assert.IsFalse (c.IsHandleCreated, "A7");
			//b.Dispose ();
			c.FindForm ();
			Assert.IsFalse (c.IsHandleCreated, "A8");
			c.Focus ();
			Assert.IsFalse (c.IsHandleCreated, "A9");

			c.GetChildAtPoint (new Point (10, 10));
			Assert.IsTrue (c.IsHandleCreated, "A10");
			c.GetContainerControl ();
			c = new Control ();
			Assert.IsFalse (c.IsHandleCreated, "A11");
			c.GetNextControl (new Control (), true);
			Assert.IsFalse (c.IsHandleCreated, "A12");
#if NET_2_0
			c.GetPreferredSize (Size.Empty);
			Assert.IsFalse (c.IsHandleCreated, "A13");
#endif
			c.Hide ();
			Assert.IsFalse (c.IsHandleCreated, "A14");
			c.Invalidate ();
			Assert.IsFalse (c.IsHandleCreated, "A15");
			//c.Invoke (new InvokeDelegate (InvokeMethod));
			//Assert.IsFalse (c.IsHandleCreated, "A16");
			c.PerformLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A17");
			c.PointToClient (new Point (100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A18");
			c = new Control ();
			c.PointToScreen (new Point (100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A19");
			c = new Control ();
			//c.PreProcessControlMessage   ???
			//c.PreProcessMessage          ???
			c.RectangleToClient (new Rectangle (0, 0, 100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A20");
			c = new Control ();
			c.RectangleToScreen (new Rectangle (0, 0, 100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A21");
			c = new Control ();
			c.Refresh ();
			Assert.IsFalse (c.IsHandleCreated, "A22");
			c.ResetBackColor ();
			Assert.IsFalse (c.IsHandleCreated, "A23");
			c.ResetBindings ();
			Assert.IsFalse (c.IsHandleCreated, "A24");
			c.ResetCursor ();
			Assert.IsFalse (c.IsHandleCreated, "A25");
			c.ResetFont ();
			Assert.IsFalse (c.IsHandleCreated, "A26");
			c.ResetForeColor ();
			Assert.IsFalse (c.IsHandleCreated, "A27");
			c.ResetImeMode ();
			Assert.IsFalse (c.IsHandleCreated, "A28");
			c.ResetRightToLeft ();
			Assert.IsFalse (c.IsHandleCreated, "A29");
			c.ResetText ();
			Assert.IsFalse (c.IsHandleCreated, "A30");
			c.SuspendLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A31");
			c.ResumeLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A32");
#if NET_2_0
			c.Scale (new SizeF (1.5f, 1.5f));
			Assert.IsFalse (c.IsHandleCreated, "A33");
#endif
			c.Select ();
			Assert.IsFalse (c.IsHandleCreated, "A34");
			c.SelectNextControl (new Control (), true, true, true, true);
			Assert.IsFalse (c.IsHandleCreated, "A35");
			c.SetBounds (0, 0, 100, 100);
			Assert.IsFalse (c.IsHandleCreated, "A36");
			c.Update ();
			Assert.IsFalse (c.IsHandleCreated, "A37");
		}
 private static void SelectNextActiveControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap)
 {
     ContainerControl control = ctl as ContainerControl;
     if (control != null)
     {
         bool flag = true;
         if (control.ParentInternal != null)
         {
             IContainerControl containerControlInternal = control.ParentInternal.GetContainerControlInternal();
             if (containerControlInternal != null)
             {
                 containerControlInternal.ActiveControl = control;
                 flag = containerControlInternal.ActiveControl == control;
             }
         }
         if (flag)
         {
             ctl.SelectNextControl(null, forward, tabStopOnly, nested, wrap);
         }
     }
     else
     {
         ctl.Select();
     }
 }
Example #12
0
 protected void CursorTop(Control C)
 {
     C.Focus();
     C.SelectNextControl(C, true, true, true, true);
 }
Example #13
0
 protected void CursorBottom(Control C)
 {
     C.Focus();
     C.SelectNextControl(C, false, true, true, true);
 }
 public static bool FocusControl(Control c, bool forceDrawFocus)
 {
     //focus the control to display its focus rectangle (simulates the behavior of hitting the tab key).
     if (forceDrawFocus)
         ControlHelper.ShowFocus(c);
     if (c.TabStop)
         return c.Focus();
     else
         return c.SelectNextControl(null, true, true, true, true);
 }