> * How do I make the Label control wrap its text? I gave it the style > wrapText:true, but it has no effect.
You need to make sure that the Label is in a container that will respect constrained preferred heights. For example, a TablePane, or a vertical BoxPane with the "fill" style set to true. > * How do I make the TextInput fields a reasonable size? Try setting the textSize property. > * Is there a straightforward way to tell the standard dialog accelerators > (Enter, Esc) what to do? In WPF, I can add IsDefault and IsCancel properties > to buttons to tell the system to "press" the button when Enter or Esc is > typed. It looks like the default behavior in Pivot is that Enter sets the > dialog result to true, Esc to false, and both close the dialog without > invoking any useful code! That means I must do something to handle those > keys or my code is very wrong. It looks like I can add a > ComponentKeyListener to the sheet to capture those keys, but that seems like > a tedious solution to have to apply to every dialog I ever write. It's also > unclear to me how I get the listener to run in the UI thread. You don't need to add explicit key listeners. You should open your dialog or sheet with a close listener - that is where you would put any "useful code". FYI, all component event listeners run in the UI thread. It is only task listeners that run on a background thread. > * How do I space the buttons nicely? In WPF, I can put them in a Grid and > set their horizontal alignment to Center. The apparently equivalent Pivot > control is TablePane, but PushButton does not accept a horizontalAlignment > style! I find this maddening. Why doesn't every component have > properties/styles that tell its container how to lay it out (alignment and > stretch/fill) within the space the container allots? I noticed, for example, > that BoxPane has style attributes fill & horiz/vert alignment, but they apply > to its children. Usually that's not what I'm looking for -- I'd want those > attributes to apply to the BoxPane itself with respect to its parent, and I > might well want different values for the children. As a really specific > example, if I want to put a Separator into a BoxPane and have it stretch > across the width of the container, I set fill:true on the BoxPane. But what > if I don't want other elements in the pane, say a button, to be stretched as > well? Am I totally missing something here? I don't think you're necessarily missing anything - I think you are just expecting layout in Pivot to work the same way it does in WPF, which is not the case. If you don't want an element to stretch to fill the box pane, simply nest it in another box pane whose fill style is not set to true. > * Are there things I could be writing more easily than I show here? I'm not sure I'd put the push buttons in the form itself. Also, I'd take advantage of form flags if possible, rather than adding your own custom error message label. You might also be able to drop the root BoxPane and just move the Form up a level. > <my:LoginSheet title="Login to server" > xmlns:bxml="http://pivot.apache.org/bxml" > xmlns:my="com.fxpal.myunity" > xmlns="org.apache.pivot.wtk" > maximumWidth="300"> > <BoxPane > styles="{padding:4, verticalAlignment:'top'}" > orientation="vertical"> > <Form> > <Form.Section> > <TextInput bxml:id="textInputName" Form.label="User Name" /> > <TextInput bxml:id="textInputPassword" Form.label="Password" > password="true" /> > <TablePane> > <columns> > <TablePane.Column width="1*"/> > <TablePane.Column width="1*"/> > </columns> > <rows> > <TablePane.Row> > <PushButton bxml:id="buttonLogin" > buttonData="Login" > styles="{horizontalAlignment:'center'}" /> > <PushButton bxml:id="buttonCancel" > buttonData="Cancel" > styles="{horizontalAlignment:'center'}" /> > </TablePane.Row> > </rows> > </TablePane> > </Form.Section> > <Form.Section> > <Label bxml:id="labelProblem" styles="{wrapText:true, > color:'red'}" /> > </Form.Section> > </Form> > </BoxPane> > </my:LoginSheet>
