Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect property grid item generation #815

Closed
leonid-galperin opened this issue May 7, 2024 · 2 comments
Closed

Incorrect property grid item generation #815

leonid-galperin opened this issue May 7, 2024 · 2 comments

Comments

@leonid-galperin
Copy link

leonid-galperin commented May 7, 2024

When creating property grid item with name pgiActive10 and label Active generated source looks like:
pgiActive10 = pgpType1->Append( new wxIntProperty( wxT("Active"), wxT("Active") ) );
This makes impossible to create property grid items with same label under different categories.

It's better be:
pgiActive10 = pgpType1->Append( new wxIntProperty( wxT("Active"), wxT("pgiActive10") ) );

Looks like it's enough to change propGridItem template in plugins\additional\xml\data.cppcode to:

<templates class="propGridItem"> <template name="declaration">wxPGProperty* $name;</template> <template name="construction"> #ifequal $type "Category" @{ $name = #parent $name->Append( new wxPropertyCategory( $label, wxT("$name") ) ); @} #ifnotequal $type "Category" @{ $name = #parent $name->Append( new wx${type}Property( $label, wxT("$name") ) ); #ifnotnull $help @{ #nl #parent $name->SetPropertyHelpString( $name, $help ); @} @} </template> </templates>

@sodevel
Copy link
Member

sodevel commented May 14, 2024

I see the issue, wxFB takes a shortcut and uses the label for both properties, which causes the error in your use case.

I don't think it is a good idea to use the widget name for the name property though, the widget name is more like an implementation detail and should not be used as part of an application data model. Also, the widget name must be a valid identifier in the generated code, so this limits what characters you may use for it.

A better approach would be to add a new property for this value so that the user can specify the value directly. This is a bit tricky because the most fitting name is already used, also it would be nice to keep the default of using the label if this value is not specified.

@leonid-galperin
Copy link
Author

Agree. Creating dedicated name property would be the best solution.

Even better is to add kind of unique integer identifier to find required wxPGProperty e.g when processing OnPropertyGridChanged or add separate OnChange event for wxPGProperty, but so far it's not supported by wxWidgets so nothing wxFB can really do about it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants