New custom attribute idea for setting parent
Mark Gaylard <[email protected]>
| Newsgroups | gmane.comp.embedded.carlsbad-cubes |
|---|---|
| Message-ID | <[email protected]> |
I have a xml file specifying a frame with a menu bar and a tabbed panel that can have its contents dynamically updated (plugged-in). The contents of the tabbed panels are in different xml files. My wish is to have these content xml files specify their own main menu additions. At the moment, I can't do this. There are two ways I can think of being able to do the above. 1) Add a new custom Swixml attribute called "parent". The value of this attribute has to match a previously created component with a matching "id" attribute. When the parser sees this "parent" attribute, it adds the component as a child of the component specified by the attribute. ie: uses the component with the specified id as the parent, not the one that is the parent of the xml element with the "parent" attribte. eg: (xml file 1) <frame> <menubar id="mainMenu"> <menu id="fileMenu" text="File"/> <menu text="Edit"/> </menubar> </frame> (xml file 2) <component> <menu parent="mainMenu" text="Custom Menu"/> <menuItem parent="fileMenu" text="Custom File Menu Item"/> </component> 2) Add a new custom Swixml attribute (can't think of a good name at the moment, "is" maybe?) that specifes that this component IS the same component as the one with the same "id" attribute. When the parser sees this attribute, it doens't create a new component, it just uses the one it created earlier. eg: (using xml file 1 from above) (xml file 2) <menubar is="mainMenu"> <menu text="Custom Menu"/> <menu is="fileMenu"> <menuItem text="Custom File Menu Item"/> </menu> </menubar> I kind of like option 1 because "parent" is a lot more obvious to me than "is", but at the same time I like option 2 because the second xml file doesn't need a special root element (this wouldn't always be the case, but is needed in this example). Of course, this technique isn't just for menus, it can be for any component (I could use this for something else I'm doing that currently requires me to jump through a few hoops). What do people think? Mark.