-
Notifications
You must be signed in to change notification settings - Fork 78
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
Duplicate parent id in custom control #336
Comments
I think we've tried to find the reason for that duplicate id part some time ago but haven't been succesful iirc 😉 However you shouldn't rely on the internal format of the id at all and iirc you don't have to! You can lookup any sub-element by its regular id only. Nifty should take care of the resolving internally, so you should be able to simply issue a element.findElementByName("imageButtonImage"). |
Ok When a ElementType is created, the method resolveIds take care of changing the #id to parentId#id So, let's say I have :
What hapens is (in pseudo code) :
The effect will get worse and worse the more you nest controls. To prevent that, I propose the following change :
What will then happens :
This solution should stay correct whatever the number of nested controls. This is a little contribution to thanks you for all the time you invested into nifty-gui. Thanks a lot !! |
I have a custom ImageButton control defined as :
that works as intended. When I use this control in a panel, and I give it an id (let's say "someButtonId"), the image inside this controle get "someButtonId#imageButtonImage" as id, as expected, and the DefaultImageButtonController is able to get the Image element with :
element.findElementByName(element.getId() + "imageButtonImage");
in its bind method.
Now I created a more complex custom control that use an imageButton control inside :
If I use this controle (with id="someArmyCardPanelId"), in the DefaultImageButtonController, element.getId() returns "someArmyCardPanelId#putOnMapButton", as expected. However, element.findElementByName(element.getId() + "imageButtonImage"); returns null. I checked the elements tree, and found that the image element inside the imageButton control got "someArmyCardPanelId#putOnMapButton#putOnMapButton#imageButtonImage" as id.
Why is "putOnMapButton" twice in this id ? I was expecting "someArmyCardPanelId#putOnMapButton#imageButtonImage"
The text was updated successfully, but these errors were encountered: