https://bugzilla.novell.com/show_bug.cgi?id=364488
User [EMAIL PROTECTED] added comment https://bugzilla.novell.com/show_bug.cgi?id=364488#c3 Andreia Gaita <[EMAIL PROTECTED]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID --- Comment #3 from Andreia Gaita <[EMAIL PROTECTED]> 2008-11-23 09:47:34 MST --- Good thing that it does, too. Notes for future reference, because this really needs to be written down somewhere... On your example: 1) OnEnter is called when focus is set to the textBox control (if this is the first Enter event, it's because textBox is the first innermost child, so it gets set by default. If this is not the first time OnEnter is called, welcome to infinite loop hell). 2)You then set focus to the listBox via a Select call. This makes the focus handling code start from the beginning, i.e., generate Enter calls from the top again. 3) The panel receives an Enter event because of 2), which activates listBox via a Select call. Since listBox is already activated, it does nothing and goes on to the next Select call, which activates the textBox. Goto 1), rinse, repeat ad nauseaum So why does the panel always get an Enter event when the only thing you're doing is changing which panel child is focused? All the controls are inside the Panel, so the focus should always be in the panel no matter what child is selected, right? Well, it just so happens that although Panel can have child controls, it is not a ContainerControl, it's just a regular Control. Only ContainerControls can get to have special handling code to control how their children are focused, and all Enter/Leave events are fired from the top of the chain - top being up until, but not including, the ContainerControl which is the parent of the control that's getting entered. This last part is important, because it means that ContainerControls only get Enter/Leave events fired if the focus is switching to another ContainerControl. This means that if you had put your three controls (text, button and list) inside a UserControl instead of a Panel, it would not go into an infinite loop, because the Enter event would be fired the first time (when focus is set by default to the textbox), and it would never be fired again until for some reason you made the focus go away to another container - let's say by forcing focus on the top Form, which would cause a Leave event on the UserControl, then an Enter event again on it (because all the focusable controls of the Form would be inside the UserControl in our little example). By the way, it's not possible to make a ContainerControl (like a Form or a UserControl) the primary focused control of an app, since it's focus handling code automatically forces focus on the first focuseable child. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
