News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

wxSmith: control construction lines don't set control's name

Started by mandrav, July 02, 2006, 11:43:29 AM

Previous topic - Next topic

mandrav

I noticed that the control constructors in the generated code don't use all the arguments.
For example, here's a wxTextCtrl's ctor generated by wxSmith:
Code ("cpp") Select

txtFolder = new wxTextCtrl(this,ID_TEXTCTRL1,_("Text"),wxDefaultPosition,wxDefaultSize,0);


It's missing the validator and name arguments. For the validator, I don't care. wxSmith can't work with validators anyway. But the name is important, I think. I 'd expect this ctor to be generated:
Code ("cpp") Select

txtFolder = new wxTextCtrl(this,ID_TEXTCTRL1,_("Text"),wxDefaultPosition,wxDefaultSize,0,wxDefaultValidator,_T("txtFolder"));


Notice that it's setting the control's name too. Without this, calls to wxWindow::FindWindowByName() fail.

Is this intentional? Can this be fixed easily?
Be patient!
This bug will be fixed soon...

byo

It shouldn't be hard to add. Of course with name, validators won't be supported in near future ;). I haven't added support for name because it could be little bit confusing for new users. There's variable name, identifier and widget name. All those can be used to identify and find widget.

The easiest solution would be to use variable name as widget name too. Hope this would be enough ;)
(I don't want to add any other standard properties do the "confusing" problem won't appear)
I'll try code it tomorrow.

mandrav

Quote from: byo on July 02, 2006, 12:21:38 PM
The easiest solution would be to use variable name as widget name too. Hope this would be enough ;)

It' s the correct thing to do, too :)
That's what other XRC editors do...

It's no big deal, take your time. It just struk me today why my calls to wxWindow::FindWindowByName() would fail ;)
Be patient!
This bug will be fixed soon...

byo

Ok, one small change. I've looked into xrc sourcecode and it uses id for setting up name. So it will be better to do it the same way. So in wxSmith, name won't be initialized with variable name but with string representation of identifier.

mandrav

Be patient!
This bug will be fixed soon...