Author: andreia
Date: 2007-05-30 20:59:14 -0400 (Wed, 30 May 2007)
New Revision: 78284
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContainerControl.cs
Log:
ContainerControl.cs: Raise Validation and Enter/Leave events
even if there is no Form, and set active_control earlier, just
before firing Enter events (toshok's patches).
Fixes #80647
2007-05-30 Andreia Gaita <[EMAIL PROTECTED]>
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-05-31 00:52:47 UTC (rev 78283)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-05-31 00:59:14 UTC (rev 78284)
@@ -1,3 +1,9 @@
+2007-05-30 Andreia Gaita <[EMAIL PROTECTED]>
+
+ ContainerControl.cs: Raise Validation and Enter/Leave events
+ even if there is no Form and set active_control earlier, just
+ before firing Enter events (toshok's patches). Fixes #80647.
+
2007-05-30 Jackson Harper <[EMAIL PROTECTED]>
* TextControl.cs: Redid the pageup/pagedown a little to simplify
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContainerControl.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContainerControl.cs
2007-05-31 00:52:47 UTC (rev 78283)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContainerControl.cs
2007-05-31 00:59:14 UTC (rev 78284)
@@ -79,92 +79,90 @@
// Fire the enter and leave events if possible
Form form = FindForm ();
- if (form != null) {
- Control active =
GetMostDeeplyNestedActiveControl (form);
- Control common_container =
GetCommonContainer (active, value);
- ArrayList chain = new ArrayList ();
- ArrayList validation_chain = new
ArrayList ();
- Control walk = active;
+ Control active =
GetMostDeeplyNestedActiveControl (form == null ? this : form);
+ Control common_container = GetCommonContainer
(active, value);
+ ArrayList chain = new ArrayList ();
+ ArrayList validation_chain = new ArrayList ();
+ Control walk = active;
- // we split this up into three steps:
- // 1. walk up the tree (if we need
to) to our root, firing leave events.
- // 2. validate.
- // 3. walk down the tree (if we need
to), firing enter events.
+ // we split this up into three steps:
+ // 1. walk up the tree (if we need to) to
our root, firing leave events.
+ // 2. validate.
+ // 3. walk down the tree (if we need to),
firing enter events.
- // "our root" is either the common
container of the current active
- // control and the new active control,
or the current active control,
- // or the new active control. That is,
it's either one of these three
- // configurations:
+ // "our root" is either the common container of
the current active
+ // control and the new active control, or the
current active control,
+ // or the new active control. That is, it's
either one of these three
+ // configurations:
- // (1) root (2) new
(3) current
- // / \ / \
/ \
- // ... ... ... ...
... ...
- // / \ /
\
- // current new current
new
+ // (1) root (2) new
(3) current
+ // / \ / \
/ \
+ // ... ... ... ...
... ...
+ // / \ /
\
+ // current new current
new
- // note (3) doesn't require any upward
walking, and no leave events are generated.
- // (2) doesn't require any
downward walking, and no enter events are generated.
+ // note (3) doesn't require any upward walking,
and no leave events are generated.
+ // (2) doesn't require any downward
walking, and no enter events are generated.
- // as we walk up the tree, we generate
a list of all controls which cause
- // validation. After firing the leave
events, we invoke (in order starting from
- // the most deeply nested) their
Validating event. If one sets CancelEventArgs.Cancel
- // to true, we ignore the control the
user wanted to set ActiveControl to, and use
- // the Validating control instead.
+ // as we walk up the tree, we generate a list
of all controls which cause
+ // validation. After firing the leave events,
we invoke (in order starting from
+ // the most deeply nested) their Validating
event. If one sets CancelEventArgs.Cancel
+ // to true, we ignore the control the user
wanted to set ActiveControl to, and use
+ // the Validating control instead.
- bool fire_enter = true;
- Control root = common_container;
+ bool fire_enter = true;
+ Control root = common_container;
- // Generate the leave messages
- while (walk != common_container) {
- if (walk == value) {
- root = value;
- fire_enter = false;
- break;
- }
- walk.FireLeave ();
- /* clear our idea of the active
control as we go back up */
- if (walk is ContainerControl)
-
((ContainerControl)walk).active_control = null;
+ // Generate the leave messages
+ while (walk != common_container) {
+ if (walk == value) {
+ root = value;
+ fire_enter = false;
+ break;
+ }
+ walk.FireLeave ();
+ /* clear our idea of the active control
as we go back up */
+ if (walk is ContainerControl)
+
((ContainerControl)walk).active_control = null;
- if (walk.CausesValidation)
- validation_chain.Add
(walk);
+ if (walk.CausesValidation)
+ validation_chain.Add (walk);
- walk = walk.Parent;
- }
+ walk = walk.Parent;
+ }
- for (int i = 0; i <
validation_chain.Count; i ++) {
- if (!ValidateControl
((Control)validation_chain[i])) {
- value =
(Control)validation_chain[i];
- fire_enter = true;
- }
+ for (int i = 0; i < validation_chain.Count; i
++) {
+ if (!ValidateControl
((Control)validation_chain[i])) {
+ value =
(Control)validation_chain[i];
+ fire_enter = true;
}
+ }
- if (fire_enter) {
- walk = value;
- while (walk != root) {
- chain.Add (walk);
- walk = walk.Parent;
- }
+ active_control = value;
- for (int i = chain.Count - 1; i
>= 0; i--) {
- walk = (Control) chain
[i];
- walk.FireEnter ();
- }
+ if (fire_enter) {
+ walk = value;
+ while (walk != root) {
+ chain.Add (walk);
+ walk = walk.Parent;
}
- walk = this;
- Control ctl = this;
- while (walk != null) {
- if (walk.Parent is
ContainerControl) {
- ((ContainerControl)
walk.Parent).active_control = ctl;
- ctl = walk.Parent;
- }
- walk = walk.Parent;
+ for (int i = chain.Count - 1; i >= 0;
i--) {
+ walk = (Control) chain [i];
+ walk.FireEnter ();
}
}
- active_control = value;
+ walk = this;
+ Control ctl = this;
+ while (walk != null) {
+ if (walk.Parent is ContainerControl) {
+ ((ContainerControl)
walk.Parent).active_control = ctl;
+ ctl = walk.Parent;
+ }
+ walk = walk.Parent;
+ }
if (this is Form)
CheckAcceptButton();
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches