Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: frithjofh on October 20, 2007, 07:30:03 pm

Title: wxSmith event management
Post by: frithjofh on October 20, 2007, 07:30:03 pm
hi everybody,

and special hi to byo for the great work  :D

maybe thhis is a request feature, but i'll post it here anyway: (two things)

1) it might seem silly, and after a little bit of thinking and reading i found out myself, that connect(...) with nothing in front of it means the same as this->connect(...), but it would be no problem of work as the plugin writes the code and for newbies like me it would put it a little bit clearer... :)

2) the former let me to the fact that as it is wxSmith only allows for events to be connected to the "this" , as to say to the top most class in that one particular file, like the main frame, wether it could make sense to connect to some intermediate object child of main frame but parent to the widget which throws the event. and this even more as it is posible to set the extra style of wxWX_EX_BLOCK_EVENTS for all and every widget.

i sugest  :wink: : having a nother column in the envents part of the properties dialog wher one can choose out of a drop down list for every event which parent(s) of the particular widget will get connected to the "connect(bla,bla,bla,...)" instead of plain and simple "this"

i can't implement this, im still too bad a programmer  :?, and surly you will give me enough good arguments why my suggestion(s) don't make that much sense as they do to me... :D

greetings from spain

frithjofh
Title: Re: wxSmith event management
Post by: byo on October 22, 2007, 10:03:01 pm
Hi

Thanks for your greetings :)

In fact wxSmith does not always Connect to "this" class. It does it whether it's possible. There are some events (like for example EVT_PAINT in wxPanel item) which must be connected directly to item which generates the event. But such events are not standard (and to be honest, wxWidgets doesn't like them in many cases).

From the developer's point of view it doesn't matter whether events connect to "this" or to partiular item as long as events are forwarded to parents. As you've noticed, wxWX_EX_BLOCK_EVENTS can stop the chain, but if you specify this style, you state that you don't want to have any events seen in the resource from such item so you definitely wouldn't like to recieve them (which would take place if connecting directly to item).

Also connecting to "this" is much more natural for wxWidgets, it works similarry to declaring event table. In event tables you don't even have possibility to connect handler to some child item (that's why wxSmith uses Connect function which gives more control over events in whole resource). So I would stay with current implementation (also adding third column to wxPropertyGrid would be quite hard since we don't maintain this item ourselves).

You also talked about extra "this->" before connect. That could be an option. But personally I would like to avoid it - it could help unerstand newbies that Connect without any prefix is called from "this" item ;)

Regards

   BYO