[Mono-bugs] [Bug 322904] UserControl.OnEnter, OnLeave are not called when the user clicks on controls

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Nov 6 11:15:39 EST 2007


https://bugzilla.novell.com/show_bug.cgi?id=322904#c1


George Giolfan <georgegiolfan at yahoo.com> changed:

           What    |Removed                                         |Added
----------------------------------------------------------------------------
             Status|CLOSED                                          |REOPENED
         Resolution|FIXED                                           |




--- Comment #1 from George Giolfan <georgegiolfan at yahoo.com>  2007-11-06 09:15:38 MST ---
The patch for bug 325809 causes a regression. Sorry.
The attached patch simply reintroduces the code that was removed from Control.
This is not enough however, because the following test fails. The same thing
happens for ListView (stack trace reveals that it calls Control.FocusInternal
when it gets a WM_LBUTTONDOWN).

using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;

static class Test
{
        static void Main ()
        {
                new TestForm ().Show ();
        }
}

class TestForm : Form
{
        FocusTestControl c1 = new FocusTestControl ();
        FocusTestControl c2 = new FocusTestControl ();

        public TestForm ()
        {
                c1.Text = "1";
                c2.Text = "2";
                c2.Dock = DockStyle.Fill;
                Controls.AddRange (new Control [] { c1, c2 });
        }

        protected override void OnLoad (EventArgs e)
        {
                base.OnLoad (e);
                Debug.Assert (!c1.Focused, "1");
                Debug.Assert (!c2.Focused, "2");
                Debug.Assert (ActiveControl == null, "3");
                Debug.Assert (c1.SelectCalls == 0, "4");
                Debug.Assert (c2.SelectCalls == 0, "5");
                Debug.Assert (c2.OnMouseDownCalls == 0, "6");
                Debug.Assert (c2.OnEnterCalls == 0, "7");
                c2.SimulateClick ();
                Debug.Assert (!c1.Focused, "1 1");
                Debug.Assert (!c2.Focused, "2 1");
                Debug.Assert (ActiveControl == null, "3 1");
                Debug.Assert (c1.SelectCalls == 0, "4 1");
                Debug.Assert (c2.SelectCalls == 0, "5 1");
                Debug.Assert (c2.OnMouseDownCalls == 1, "6 1");
                Debug.Assert (c2.OnEnterCalls == 0, "7 1");
        }
}

class FocusTestControl : UserControl
{
        public int SelectCalls;
        public int OnMouseDownCalls;
        public int OnEnterCalls;

        public void SimulateClick ()
        {
                const int WM_LBUTTONDOWN = 0x0201;
                const int MK_LBUTTON = 0x0001;
                Message m = new Message ();
                m.Msg = WM_LBUTTONDOWN;
                m.WParam = (IntPtr)MK_LBUTTON;
                Debug.Assert (CanSelect);
                WndProc (ref m);
        }

        protected override void Select (bool directed, bool forward)
        {
                base.Select (directed, forward);
                SelectCalls++;
        }

        protected override void OnMouseDown (MouseEventArgs e)
        {
                base.OnMouseDown (e);
                OnMouseDownCalls++;
        }

        protected override void OnEnter (EventArgs e)
        {
                base.OnEnter (e);
                OnEnterCalls++;
        }
}


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list