FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Control Events

 
Post new topic   Reply to topic     Forum Index -> DFL
View previous topic :: View next topic  
Author Message
dsimcha



Joined: 24 Oct 2008
Posts: 16

PostPosted: Wed Jul 14, 2010 10:35 pm    Post subject: Control Events Reply with quote

The double-click event in the following code does not work. When the area the Foo control occupies is double-clicked, nothing happens.

Code:
import dfl.all;

class Foo : Control {
    PictureBox pbox;

    this() {
        pbox = new PictureBox;
        this.size = Size(800, 600);
        pbox.setBounds(0, 0, 800, 600);
        pbox.parent = this;
    }
}

class MyForm : Form {
    void fooEvent(Control c, EventArgs ea) {
        msgBox("You double clicked.");
    }

    Foo foo;

    this() {
        foo = new Foo;
        foo.parent = this;
        foo.doubleClick ~= &fooEvent;
    }
}

void main() {
    Application.run(new MyForm);
}



However, when I change:
Code:
foo.doubleClick ~= &fooEvent;


to

Code:
foo.pbox.doubleClick ~= &fooEvent;


then double-clicking in the area occupied by the Foo control produces the intended result. Can someone please explain this behavior to me?
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Fri Jul 16, 2010 1:58 pm    Post subject: Re: Control Events Reply with quote

Events don't bubble up to the parent, but here's a template you can use: DFL Control input events propagate to parent - notice line 100
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DFL All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group