Because nature and Windows Forms DLL came to be referred to, I became convenient.
However, does not a namespace collide with WPF DLL?
Forums
Namespace collision?
7 posts
• Page 1 of 1
Re: Namespace collision?
I'm not exactly sure what you are asking, but I'll try to help.
If you have two classes with the same name, but in different namespaces, then you can access them by their fully qualified name:
Does that help?
If you have two classes with the same name, but in different namespaces, then you can access them by their fully qualified name:
# untested
use System.Windows.Controls
use System.Windows.Forms
class X
def main is shared
print System.Windows.Controls.Button
print System.Windows.Forms.Button
Does that help?
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: Namespace collision?
Thank you.
However, it was my misunderstanding with most.
Please forget WPF.
Can not compile the following def.
The former cobra was possible.
However, it was my misunderstanding with most.
Please forget WPF.
Can not compile the following def.
The former cobra was possible.
...
def onClick(sender as Object, args as EventArgs)
MessageBox.show('You clicked Button', 'Click')
...
- arisawa
- Posts: 51
Re: Namespace collision?
(1) Be sure to use Cobra from source: HowToInstallFromSource
(2) This works for me:
(2) This works for me:
use System.Windows.Forms
class Program
def main is shared
Program().run
def run
b = Button(text='Click me')
listen b.click, ref .onClick
def onClick(sender as Object, args as EventArgs)
MessageBox.show('You clicked Button', 'Click')
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: Namespace collision?
Umm...
The installation seems to have succeeded.
There is still a problem.
Nothing is displayed even if I can compile it in the shown example.
The template which I use is the following cords which are near to 'HowTo/380-WinForms.cobra'.
When a name of event handler is 'onClick' then, I get an error.
When it is another name, I do not seem to have any problem. (e.g. btn_onClick)
The installation seems to have succeeded.
There is still a problem.
Nothing is displayed even if I can compile it in the shown example.
The template which I use is the following cords which are near to 'HowTo/380-WinForms.cobra'.
use System.Windows.Forms
use System.Drawing
class MyForm
inherits Form
def init
.text = 'Click'
btn = Button()
btn.parent = this
listen btn.click, ref .onClick
def onClick(sender as Object, args as EventArgs)
MessageBox.show('You clicked Button', 'Click')
class Program
def main is shared
Application.run(MyForm())
When a name of event handler is 'onClick' then, I get an error.
error: Could not find an overload for "onClick" with zero arguments.
When it is another name, I do not seem to have any problem. (e.g. btn_onClick)
- arisawa
- Posts: 51
Re: Namespace collision?
The first time I ran this on Windows, it came up pretty quick. But on Mono 2.0 on Mac, my hard drive churned for 3 minutes before the the window came up. On subsequent launches on Mono, the program came up quickly. So the first Mono launch requires patience.
Regarding the name "onClick", this was a bug in Cobra regarding "listen" and overloaded methods. There is already an "onClick" in an ancestor class which caused this bug to be revealed. I have fixed the bug so now you can "svn upd" and install again.
Also, you can write this kind of code for convenience if you like:
Regarding the name "onClick", this was a bug in Cobra regarding "listen" and overloaded methods. There is already an "onClick" in an ancestor class which caused this bug to be revealed. I have fixed the bug so now you can "svn upd" and install again.
Also, you can write this kind of code for convenience if you like:
b = Button(text='Click this button', parent=this)
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: Namespace collision?
It worked well, this time.
How to write that does not appoint a type 'sender' is convenient.
It was usable in wx.NET, and a trouble of that place was settled, too.
Thank you.
How to write that does not appoint a type 'sender' is convenient.
It was usable in wx.NET, and a trouble of that place was settled, too.
Thank you.
- arisawa
- Posts: 51
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 50 guests