View previous topic :: View next topic |
Author |
Message |
The Guardian
Joined: 13 May 2007 Posts: 2
|
Posted: Mon May 14, 2007 7:50 am Post subject: Problem with click-event |
|
|
Hello
I've got a problem with DFl: When I try to compile a program with a click-event, I get the following message: Code: |
D:\PROGRA~3\dmd\import\dfl\event.d(219): static assert "DFL: Event handler must be a delegate" |
I've got no idea what I'm doing wron, so please tell me.
Whole SC: Code: |
private import dfl.all;
private import std.string;
int main()
{
Form myForm;
Label myLabel;
Button myButton;
myForm=new Form;
myForm.text="Click-Event-Test";
myLabel=new Label;
myLabel.font=new Font("Tahoma", 14f);
myLabel.text="1. Text";
myLabel.location=Point(10, 10);
myLabel.size=Size(20, 20);
myLabel.parent=myForm;
myButton=new Button;
myButton.text="Change text";
myButton.location=Point(25, 25);
myButton.parent=myForm;
myButton.click ~=&tc;
return 0;
}
private void tc(Object sender, EventArgs ea)
{
myLabel.text="2. Text";
}
|
I'm hoping that you guys can help me
Greetings
The Guardian |
|
Back to top |
|
|
Carlos
Joined: 19 Mar 2004 Posts: 396 Location: Canyon, TX
|
Posted: Mon May 14, 2007 8:19 am Post subject: |
|
|
Put tc inside of main, or make it a non-static class function. |
|
Back to top |
|
|
The Guardian
Joined: 13 May 2007 Posts: 2
|
Posted: Tue May 15, 2007 9:01 am Post subject: |
|
|
Well thanks, but could you post some SC, how you would have done it? |
|
Back to top |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Tue May 15, 2007 10:07 am Post subject: Re: Problem with click-event |
|
|
Many examples come with the DFL download. If you used the installer, you can easily find them from your start menu.
Here's some code: http://paste.dprogramming.com/dpwm1i9f.php |
|
Back to top |
|
|
|