Re: [Mono-winforms-list] Bug in System.Windows.Forms.Control:get_ContainsFocus ()?
Hi Rafael, Yes this problem exists in a much larger application involving lots of custom controls, I have just created this code to demonstrate the problem as simply as possible. I have tested the code in MS .NET and it works ok and returns False to the console as expected so I have logged a bug http://bugzilla.ximian.com/show_bug.cgi?id=78685 Thanks for your help, Paddy Rafael Teixeira wrote: > Hi Paddy, > > Why do you return base.ContainFocus instead of base.Focused from your > overriden Focused? That way you are introducing infinite recursion as > Control.ContainsFocus calls Control.Focused, that in your case is > overriden. > > In truth, unless this is just some small code to show the problem, I > don't see any need to override Focused... Even more to change its > semantics. > > Anyway if that code works in MS.NET, we should not rely on Focused to > determine partially the value of ContainsFocus (ContainsFocus also > checks children if the Control per se isn't with focus). Test it in > MS.NEt and if it works OK, please fill a bug for MWF, thanks. > > :| > > On 6/21/06, Paddy Joy <[EMAIL PROTECTED]> wrote: >> How about this code, I'm pretty sure that it instantiates button2 >> correctly now but still gives the segmentation error. >> >> I have declared the button with: >> private testbutton button2; >> >> and instantiated it with: >> this.button2 = new testbutton(); >> >> Thanks for the help, >> Paddy >> >> >> using System; >> using System.Drawing; >> using System.Collections; >> using System.ComponentModel; >> using System.Windows.Forms; >> using System.Data; >> >> namespace WindowsApplication4 >> { >> /// >> /// Summary description for Form1. >> /// >> public class Form1 : System.Windows.Forms.Form >> { >> private System.Windows.Forms.Button button1; >> private testbutton button2; >> /// >> /// Required designer variable. >> /// >> private System.ComponentModel.Container components = null; >> >> public Form1() >> { >> // >> // Required for Windows Form Designer support >> // >> InitializeComponent(); >> >> // >> // TODO: Add any constructor code after >> InitializeComponent call >> // >> } >> >> /// >> /// Clean up any resources being used. >> /// >> protected override void Dispose( bool disposing ) >> { >> if( disposing ) >> { >> if (components != null) >> { >> components.Dispose(); >> } >> } >> base.Dispose( disposing ); >> } >> >> #region Windows Form Designer generated code >> /// >> /// Required method for Designer support - do not modify >> /// the contents of this method with the code editor. >> /// >> private void InitializeComponent() >> { >> this.button1 = new System.Windows.Forms.Button(); >> this.button2 = new testbutton(); >> this.SuspendLayout(); >> // >> // button1 >> // >> this.button1.Location = new System.Drawing.Point(96, 32); >> this.button1.Name = "button1"; >> this.button1.TabIndex = 0; >> this.button1.Text = "button1"; >> this.button1.Click += new >> System.EventHandler(this.button1_Click); >> // >> // button2 >> // >> this.button2.Location = new System.Drawing.Point(96, 80); >> this.button2.Name = "button2"; >> this.button2.TabIndex = 1; >> this.button2.Text = "button2"; >> // >> // Form1 >> // >> this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); >> this.ClientSize = new System.Drawing.Size(292, 262); >> this.Controls.Add(this.button2); >> this.Controls.Add(this.button1); >> this.Name = "Form1"; >> this.Text = "Form1"; >> this.ResumeLayout(false); >> >> } >> #endregion >> >> /// >> /// The main entry point for the application. >> /// >> [STAThread] >> static void Main() >> { >> Application.Run(new Form1()); >> } >> >> private void button1_Click(object sender, System.EventArgs e) >> { >> Console.Write(button2.Focused); >> } >> } >> >> public class testbutton : System.Windows.Forms.Button >> { >> >> public testbutton() >> { >> >> >> } >> >> public override bool Focused >> { >> get >> { >> return base.ContainsFocus; >> } >> } >> >> >> >> } >> } >> >> >> > Hi, >> > >> > >> >> So do you think it could be a b
Re: [Mono-winforms-list] Contributing
Hello, > Thanks for your reply. I have simply been using the Object Browser > built into VS 2005 and typing in the enum constants that it lists. I > know that's not a decompiler or ildasm. Not entirely sure exactly > what's a reflector, so I'll ask to be sure. Is Object Browser ok? I > could only find one mention of it in the Mono mailing archive, and it > sounded ok from there. This is best produced as you read the documentation. Miguel. ___ Mono-winforms-list maillist - Mono-winforms-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-winforms-list
Re: [Mono-winforms-list] Bug in System.Windows.Forms.Control:get_ContainsFocus ()?
Hi Paddy, Why do you return base.ContainFocus instead of base.Focused from your overriden Focused? That way you are introducing infinite recursion as Control.ContainsFocus calls Control.Focused, that in your case is overriden. In truth, unless this is just some small code to show the problem, I don't see any need to override Focused... Even more to change its semantics. Anyway if that code works in MS.NET, we should not rely on Focused to determine partially the value of ContainsFocus (ContainsFocus also checks children if the Control per se isn't with focus). Test it in MS.NEt and if it works OK, please fill a bug for MWF, thanks. :| On 6/21/06, Paddy Joy <[EMAIL PROTECTED]> wrote: > How about this code, I'm pretty sure that it instantiates button2 > correctly now but still gives the segmentation error. > > I have declared the button with: > private testbutton button2; > > and instantiated it with: > this.button2 = new testbutton(); > > Thanks for the help, > Paddy > > > using System; > using System.Drawing; > using System.Collections; > using System.ComponentModel; > using System.Windows.Forms; > using System.Data; > > namespace WindowsApplication4 > { > /// > /// Summary description for Form1. > /// > public class Form1 : System.Windows.Forms.Form > { > private System.Windows.Forms.Button button1; > private testbutton button2; > /// > /// Required designer variable. > /// > private System.ComponentModel.Container components = null; > > public Form1() > { > // > // Required for Windows Form Designer support > // > InitializeComponent(); > > // > // TODO: Add any constructor code after InitializeComponent call > // > } > > /// > /// Clean up any resources being used. > /// > protected override void Dispose( bool disposing ) > { > if( disposing ) > { > if (components != null) > { > components.Dispose(); > } > } > base.Dispose( disposing ); > } > > #region Windows Form Designer generated code > /// > /// Required method for Designer support - do not modify > /// the contents of this method with the code editor. > /// > private void InitializeComponent() > { > this.button1 = new System.Windows.Forms.Button(); > this.button2 = new testbutton(); > this.SuspendLayout(); > // > // button1 > // > this.button1.Location = new System.Drawing.Point(96, 32); > this.button1.Name = "button1"; > this.button1.TabIndex = 0; > this.button1.Text = "button1"; > this.button1.Click += new > System.EventHandler(this.button1_Click); > // > // button2 > // > this.button2.Location = new System.Drawing.Point(96, 80); > this.button2.Name = "button2"; > this.button2.TabIndex = 1; > this.button2.Text = "button2"; > // > // Form1 > // > this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); > this.ClientSize = new System.Drawing.Size(292, 262); > this.Controls.Add(this.button2); > this.Controls.Add(this.button1); > this.Name = "Form1"; > this.Text = "Form1"; > this.ResumeLayout(false); > > } > #endregion > > /// > /// The main entry point for the application. > /// > [STAThread] > static void Main() > { > Application.Run(new Form1()); > } > > private void button1_Click(object sender, System.EventArgs e) > { > Console.Write(button2.Focused); > } > } > > public class testbutton : System.Windows.Forms.Button > { > > public testbutton() > { > > > } > > public override bool Focused > { > get > { > return base.ContainsFocus; > } > } > > > > } > } > > > > Hi, > > > > > >> So do you think it could be a bug with resolving the base class? It > >> seems from the trace that it is going into a continuous loop, like it is > >> calling ContainsFocus on itself. > >> > > > > To be honest, all I saw was the segfault rather than the tonnes of > > output. The baseclass seems to be working fine as well > > > > I did the following to your code and if you run it, you'll see that the > > baseclass is fine > > > > using System; > > using System.Drawing; > > using System.Collections; > > using System.ComponentModel; > > using System.Windows.Forms; > > using System.Data; > > > > namespace WinApp4
Re: [Mono-winforms-list] Bug in System.Windows.Forms.Control:get_ContainsFocus ()?
How about this code, I'm pretty sure that it instantiates button2 correctly now but still gives the segmentation error. I have declared the button with: private testbutton button2; and instantiated it with: this.button2 = new testbutton(); Thanks for the help, Paddy using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace WindowsApplication4 { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Button button1; private testbutton button2; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.button1 = new System.Windows.Forms.Button(); this.button2 = new testbutton(); this.SuspendLayout(); // // button1 // this.button1.Location = new System.Drawing.Point(96, 32); this.button1.Name = "button1"; this.button1.TabIndex = 0; this.button1.Text = "button1"; this.button1.Click += new System.EventHandler(this.button1_Click); // // button2 // this.button2.Location = new System.Drawing.Point(96, 80); this.button2.Name = "button2"; this.button2.TabIndex = 1; this.button2.Text = "button2"; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(292, 262); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); } #endregion /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.Run(new Form1()); } private void button1_Click(object sender, System.EventArgs e) { Console.Write(button2.Focused); } } public class testbutton : System.Windows.Forms.Button { public testbutton() { } public override bool Focused { get { return base.ContainsFocus; } } } } > Hi, > > >> So do you think it could be a bug with resolving the base class? It >> seems from the trace that it is going into a continuous loop, like it is >> calling ContainsFocus on itself. >> > > To be honest, all I saw was the segfault rather than the tonnes of > output. The baseclass seems to be working fine as well > > I did the following to your code and if you run it, you'll see that the > baseclass is fine > > using System; > using System.Drawing; > using System.Collections; > using System.ComponentModel; > using System.Windows.Forms; > using System.Data; > > namespace WinApp4 > { > public class Form1 : System.Windows.Forms.Form > { > private System.Windows.Forms.Button button1; > private System.Windows.Forms.Button button2; > private System.ComponentModel.Container components = null; > > public Form1() > { > InitializeComponent(); > } > > protected override void Dispose(bool disposing) > { > if (disposing) > { > if (components != null) > { > components.Dispose(); > } > } > base.Dispose(disposing); > } > > private void InitializeComponent() > { > this.button1 = new System.Windows.Forms.Button(); > this.button2 = new System.Windows.Forms.Button(); > this.SuspendLayout(); > > this.button1.Location = new System.Drawing.Point(96, 32); > this.button1.Name = "button1"; > this.button1.TabIndex = 0; > this.button1.Text = "button1"; > this.button1.Click += new System.EventHandler(this.b
Re: [Mono-winforms-list] Bug in System.Windows.Forms.Control:get_ContainsFocus ()?
Hi, > So do you think it could be a bug with resolving the base class? It > seems from the trace that it is going into a continuous loop, like it is > calling ContainsFocus on itself. To be honest, all I saw was the segfault rather than the tonnes of output. The baseclass seems to be working fine as well I did the following to your code and if you run it, you'll see that the baseclass is fine using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace WinApp4 { public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private System.ComponentModel.Container components = null; public Form1() { InitializeComponent(); } protected override void Dispose(bool disposing) { if (disposing) { if (components != null) { components.Dispose(); } } base.Dispose(disposing); } private void InitializeComponent() { this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.SuspendLayout(); this.button1.Location = new System.Drawing.Point(96, 32); this.button1.Name = "button1"; this.button1.TabIndex = 0; this.button1.Text = "button1"; this.button1.Click += new System.EventHandler(this.button1_Click); this.button2.Location = new System.Drawing.Point(96, 80); this.button2.Name = "button2"; this.button2.TabIndex = 1; this.button2.Text = "button2"; this.button2.Click += new System.EventHandler(this.button2_Click); this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(292, 262); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); } [STAThread] static void Main() { Application.Run(new Form1()); } private void button1_Click(object sender, System.EventArgs e) { Console.Write(base.ContainsFocus); } private void button2_Click(object sender, System.EventArgs e) { Console.WriteLine(base.ContainsFocus); } } } The output (at least on my box) is True (button 1 pressed - no return feed) TrueTrue (button 2 pressed) >From the looks of the original code, you've created the second button, but never properly instantated it (it is declared as private swf.button button2 at the start, but never created using this.button2 = new swf.button()). That (to me) is the most likely candidate for the breakage. TTFN Paul -- "Logic, my dear Zoe, is merely the ability to be wrong with authority" - Dr Who ___ Mono-winforms-list maillist - Mono-winforms-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-winforms-list
Re: [Mono-winforms-list] Bug in System.Windows.Forms.Control:get_ContainsFocus ()?
Thanks Paul, So do you think it could be a bug with resolving the base class? It seems from the trace that it is going into a continuous loop, like it is calling ContainsFocus on itself. Paddy > Hi, > > >> mcs base.cs -r:System.Windows.Forms -r:System.Data -r:System.Drawing >> >> run mono base.exe >> >> Click on button1. >> > > Code > > 8--> > using System; > using System.Drawing; > using System.Collections; > using System.ComponentModel; > using System.Windows.Forms; > using System.Data; > > namespace WindowsApplication4 > { > public class Form1 : System.Windows.Forms.Form > { >private System.Windows.Forms.Button button1; >private System.Windows.Forms.Button button2; >private System.ComponentModel.Container components = null; > >public Form1() >{ > InitializeComponent(); >} > >protected override void Dispose( bool disposing ) >{ > if( disposing ) > { >if (components != null) >{ > components.Dispose(); >} > } > base.Dispose( disposing ); >} > >private void InitializeComponent() >{ > this.button1 = new System.Windows.Forms.Button(); > this.button2 = new testbutton(); > this.SuspendLayout(); > > this.button1.Location = new System.Drawing.Point(96, 32); > this.button1.Name = "button1"; > this.button1.TabIndex = 0; > this.button1.Text = "button1"; > this.button1.Click += new > System.EventHandler(this.button1_Click); > > this.button2.Location = new System.Drawing.Point(96, 80); > this.button2.Name = "button2"; > this.button2.TabIndex = 1; > this.button2.Text = "button2"; > > this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); > this.ClientSize = new System.Drawing.Size(292, 262); > this.Controls.Add(this.button2); > this.Controls.Add(this.button1); > this.Name = "Form1"; > this.Text = "Form1"; > this.ResumeLayout(false); > } > > [STAThread] > static void Main() > { > Application.Run(new Form1()); > } > > private void button1_Click(object sender, System.EventArgs e) > { > Console.Write(button2.Focused); > } >} > >public class testbutton : System.Windows.Forms.Button >{ > > public testbutton() > { > } > > public override bool Focused > { > get > { >return base.ContainsFocus; > } > } >} > } > <--8 > > ContainsFocus is working fine - as a quick test I altered button2 to be > a button and created a new Click event for it as well as altering the > button1 ClickEvent - they now just return base.ContainsFocus to the > console. > > It looks more to me that there is a problem accessing something which is > not properly created (testbutton()). > > TTFN > > Paul > > ___ Mono-winforms-list maillist - Mono-winforms-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-winforms-list
Re: [Mono-winforms-list] Bug in System.Windows.Forms.Control:get_ContainsFocus ()?
Hi, > mcs base.cs -r:System.Windows.Forms -r:System.Data -r:System.Drawing > > run mono base.exe > > Click on button1. Code 8--> using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace WindowsApplication4 { public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private System.ComponentModel.Container components = null; public Form1() { InitializeComponent(); } protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } private void InitializeComponent() { this.button1 = new System.Windows.Forms.Button(); this.button2 = new testbutton(); this.SuspendLayout(); this.button1.Location = new System.Drawing.Point(96, 32); this.button1.Name = "button1"; this.button1.TabIndex = 0; this.button1.Text = "button1"; this.button1.Click += new System.EventHandler(this.button1_Click); this.button2.Location = new System.Drawing.Point(96, 80); this.button2.Name = "button2"; this.button2.TabIndex = 1; this.button2.Text = "button2"; this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(292, 262); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); } [STAThread] static void Main() { Application.Run(new Form1()); } private void button1_Click(object sender, System.EventArgs e) { Console.Write(button2.Focused); } } public class testbutton : System.Windows.Forms.Button { public testbutton() { } public override bool Focused { get { return base.ContainsFocus; } } } } <--8 ContainsFocus is working fine - as a quick test I altered button2 to be a button and created a new Click event for it as well as altering the button1 ClickEvent - they now just return base.ContainsFocus to the console. It looks more to me that there is a problem accessing something which is not properly created (testbutton()). TTFN Paul -- "Logic, my dear Zoe, is merely the ability to be wrong with authority" - Dr Who ___ Mono-winforms-list maillist - Mono-winforms-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-winforms-list
[Mono-winforms-list] Bug in System.Windows.Forms.Control:get_ContainsFocus ()?
Hi, I'm porting an application from MS. NET to Mono and I have encountered the following, maybe it's a bug or maybe it's just bad coding :-) The attached code sends Mono into a loop until it eventually crashes with a segmentation error (When button1 is clicked). Should I report this as a bug or is this just dodgy code to override the get_Focused method like this? Compile with: mcs base.cs -r:System.Windows.Forms -r:System.Data -r:System.Drawing run mono base.exe Click on button1. Code and trace attached. Thanks, Paddy using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace WindowsApplication4 { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.button1 = new System.Windows.Forms.Button(); this.button2 = new testbutton(); this.SuspendLayout(); // // button1 // this.button1.Location = new System.Drawing.Point(96, 32); this.button1.Name = "button1"; this.button1.TabIndex = 0; this.button1.Text = "button1"; this.button1.Click += new System.EventHandler(this.button1_Click); // // button2 // this.button2.Location = new System.Drawing.Point(96, 80); this.button2.Name = "button2"; this.button2.TabIndex = 1; this.button2.Text = "button2"; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(292, 262); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); } #endregion /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.Run(new Form1()); } private void button1_Click(object sender, System.EventArgs e) { Console.Write(button2.Focused); } } public class testbutton : System.Windows.Forms.Button { public testbutton() { } public override bool Focused { get { return base.ContainsFocus; } } } } . . . . . . . . . . . . . . . . . . . . . . . . . . ENTER: System.Windows.Forms.Button:OnClick (System.EventArgs)(this:0x5c2a8[System.Windows.Forms.Button WindowsForm.exe], [System.EventArgs:0x2ff68], ) . . . . . . . . . . . . . . . . . . . . . . . . . . . ENTER: System.Windows.Forms.Control:OnClick (System.EventArgs)(this:0x5c2a8[System.Windows.Forms.Button WindowsForm.exe], [System.EventArgs:0x2ff68], ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . ENTER: (wrapper delegate-invoke) System.MulticastDelegate:invoke_void_object_EventArgs (object,System.EventArgs)(this:0x4c5a0[System.EventHandler WindowsForm.exe], [System.Windows.Forms.Button:0x5c2a8], [System.EventArgs:0x2ff68], ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ENTER: WindowsApplication4.Form1:button1_Click (object,System.EventArgs)(this:0x3[WindowsApplication4.Form1 WindowsForm.exe], [System.Windows.Forms.Button:0x5c2a8], [System.EventArgs:0x2ff68], ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ENTER: WindowsApplication4.testbutton:get_Focused ()(this:0x5c000[WindowsApplication4.testbutton WindowsForm.exe], ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ENTER: System.Windows.Forms.Control:get_ContainsFocus ()(this:0x5c000[WindowsApplication4.testbutton WindowsForm.exe], ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ENTER: WindowsApplication4.testbutton:get_Focused ()(this:0x5c000[WindowsApplication4.testbutton WindowsForm.exe], ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ENTER: System.Windows.Forms.Control:get_ContainsFocus ()(this:0x5c000[WindowsApplication4.testbutton WindowsForm.exe], ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ENTER: WindowsApplication4.testbutton:get_Focused ()(this:0x5c000[WindowsApplication4.testbutton WindowsForm.exe], ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ENTER: System.Windows.Forms.Control:get_ContainsFocus ()