2

I'm creating a UI using XUL. I have N buttons I would like to add, and all I care about is that they all show on the form, regardless of the form's size. If I add a new button later or remove an existing button, I'd like to just delete the one <button> element rather than having to move things around inside grid or hbox/vbox elements.

Is there a way to get this behavior? It seems odd that I can't achieve this, given that it's the default behavior in HTML.

Nathan
  • 1,218
  • 3
  • 19
  • 35
  • Perhaps you could rephrase your question. In what sense do you have to "move things around inside" when you remove a button? – pc1oad1etter May 05 '09 at 02:12
  • 1
    I think he means that he wants buttons to continue on the next "line" if they occupy too much space and instead of eg. 1 row of buttons become 2 rows. This is probably what he means : http://java.sun.com/docs/books/tutorial/uiswing/layout/flow.html – lithorus May 05 '09 at 04:12
  • lithorus is correct. Without the ability to have things automatically 'flow' to a second line when appropriate, I have to re-balance elements among grid or {h,v}box containers in order to have them show up in a way that works visually. To attempt to explain a visual concept in words: let's say I have 6 buttons I want to place on the form, and my form is 3 buttons wide. How should I place those buttons such that adding/removing buttons requires the least amount of work? Also consider that the form can be resized. – Nathan May 06 '09 at 00:27

3 Answers3

2

Try this:

 <description><button/><button/><button/><button/><button/>
              <button/><button/><button/><button/></description>

XUL <description> on MDC

PS. you probably want to rethink your UI if you have a large and non-constant number of buttons in a row :)

Nickolay
  • 31,095
  • 13
  • 107
  • 185
  • Thanks for the suggestion; I'll give that a try and let you know how it works. The number of UI elements on each row is constant, but if I want to add a new one then it's a pain in my ass, and it makes form resizing awkward. – Nathan Jul 12 '09 at 18:39
  • Doesn't appear to work when inside a tabpanel element. The contents of the tab panel don't flow. – Nathan Dec 07 '10 at 04:13
  • @Nathan: instead of just saying "it doesn't work" you could have provided the testcase demonstrating what exactly you tried. That would increase the chances of someone looking into the problem for you. – Nickolay Dec 07 '10 at 09:49
1

You need add display: block; to the style of the parent element.

See http://starkravingfinkle.org/blog/2008/06/xul-tip-wrapping-boxes/ for details

Mark
  • 11
  • 1
0

HTML and XUL do handle this differently on a fundamental level. XUL is box-based. You can see the difference discussed on MDC here. It's not entirely clear (to me) from the documentation, but nsBoxToBlockAdaptor might be a step in the direction you seek.

pc1oad1etter
  • 8,549
  • 10
  • 49
  • 64
  • 1
    nsBoxToBlockAdaptor is an internal class in Gecko implementation, and it does not even exist these days. – Nickolay Jul 09 '09 at 15:12