Flex form layout - add first child vertically aligned with label - apache-flex

In flex form layout
<mx:Form id="form">
<mx:FormItem label="horizontal:">
<mx:Text text="test"/>
</mx:FormItem>
</mx:Form>
the output will be
horizontal 'test'
But my constraint is i want to align the textbox(first child of the form item ) vertically with the label. How can i do this ?Any inputs invited

You could override the form / formitem class to change the layout approach by overriding updateDisplayList method.
You could also try something like this:
<mx:Form id="form">
<mx:FormItem direction="vertical">
<mx:Label text="horizontal:"/>
<mx:Text text="test"/>
</mx:FormItem>
</mx:Form>

For Spark-Forms it works differently. Take a look at this very good description: https://opensource.adobe.com/wiki/display/flexsdk/Spark+Form
From the source above:
<fx:Style>
#namespace s "library://ns.adobe.com/flex/spark";
#stackedForm s|FormItem
{
skinClass : ClassReference("spark.skins.spark.StackedFormItemSkin");
}
</fx:Style>
<s:Form id="stackedForm">
<s:FormItem label="Address" sequenceLabel="1." required="true" >
<s:TextInput width="100%"/>
<s:TextInput width="100%"/>
<s:TextInput width="100%"/>
<s:helpContent>
<s:Label text="(ex. 123 Main Street)" baseline="24"/>
<s:Button label="?" width="30" baseline="24" x="120"/>
</s:helpContent>
</s:FormItem>
<s:FormItem label="City" sequenceLabel="2." required="true">
<s:TextInput width="100%"/>
</s:FormItem>
<s:FormItem label="State" sequenceLabel="3.">
<s:ComboBox dataProvider="{statesDP}" width="100%"/>
</s:FormItem>
<s:FormItem label="ZipCode" sequenceLabel="4." required="true">
<s:TextInput widthInChars="4" restrict="0123456789"/>
<s:helpContent>
<s:Label text="Will appear in your profile" left="0" right="0" baseline="24"/>
</s:helpContent>
</s:FormItem>
</s:Form>

Related

How do I set the minimum label width in a Spark FormItem?

Is there a way to set the minimum label width in a Spark FormItem? I have the following code and the checkbox is way to close to the label. I'd like to be able set a minimum label width.
<s:Form id="form1" width="100%">
<s:layout>
<s:FormLayout id="formLayout1" />
</s:layout>
<s:FormItem label="Numbers" >
<s:CheckBox id="numbersCheckbox" />
</s:FormItem>
<s:FormItem label="Letters" >
<s:CheckBox id="lettersCheckbox" />
</s:FormItem>
<s:FormItem >
<s:Button id="myButton"
label="My Label">
</s:Button>
</s:FormItem>
</s:Form>
I've come up with a partial solution but it has side effects. I use the following CSS and it moves the column over but it also affects any label with the id, "labelDisplay". Look at the button when using this CSS:
spark|FormItemSkin #labelDisplay {
paddingRight: 50;
color: red;
}
I think the cleanest or rather the best reusable approach would be to create your own FormItemSkin to modify the gap between the FormItem's label and the content.
A quick solution could be the usage of separate layout objects for your form items:
<s:Form id="form1" width="100%" >
<s:layout>
<s:FormLayout id="formLayout1"/>
</s:layout>
<s:FormItem label="Numbers" >
<s:layout>
<s:HorizontalLayout paddingLeft="10"/>
</s:layout>
<s:CheckBox id="numbersCheckbox" />
</s:FormItem>
<s:FormItem label="Letters" >
<s:layout>
<s:HorizontalLayout paddingLeft="10"/>
</s:layout>
<s:CheckBox id="lettersCheckbox" left="20" />
</s:FormItem>
</s:Form>

VScrollbar is not visible untill it is clicked

What should be added in order to the vertical scrollbar to be visible without to be clicked or touched ? Here is image of screen :
Here is code :
<s:Scroller width="100%" height="100%">
<s:VGroup width="100%" height="100%" paddingTop="5" verticalAlign="middle" horizontalAlign="center">
<s:TextInput id="chp1" width="50%"/>
<s:TextInput id="chp2" width="50%"/>
<s:Button label="Enregistrer" click="enregistrer(event)" styleName="btn"/>
<s:Label/>
<s:Button label="Lire" click="lire(event)" styleName="btn" />
<s:TextArea id="area"/>
<s:Label/>
<s:HGroup>
<s:Button label="Envoyer" click="send(event)" styleName="btn" />
<s:Button label="Retour" click="navigator.popView()" styleName="btn" />
</s:HGroup>
<s:TextArea id="resultHTTP"/>
<s:TextInput id="h_url" text="{url}" visible="false"/>
</s:VGroup>
</s:Scroller>
As you see the vertical scrollbar at the right of the screen is not visible. So how to make it visible anytime ?
Please try this, on your scroller:
verticalScrollPolicy = "on"
Update:
What about trying this:
interactionMode="mouse"
;)

hide hgroup on condition

i have my hGroups as like
<s:HGroup width="100%" verticalAlign="baseline" id="Scale">
<s:Label width="80" text="Scale:" fontWeight="bold" textAlign="right"/>
<s:DropDownList id="scaleDropdown" minWidth="155" change="handleScaleDropdownChange(event)"/>
</s:HGroup>
<s:HGroup width="100%" verticalAlign="baseline" id="Precision">
<s:Label width="80" text="Precision:" fontWeight="bold" textAlign="right"/>
<s:DropDownList id="precisionDropdown" minWidth="155" change="handlePrecisionDropdownChange(event)"/>
</s:HGroup>
<s:HGroup width="100%" verticalAlign="baseline" id="Units">
<s:Label width="80" text="Units:" fontWeight="bold" textAlign="right"/>
<s:DropDownList id="unitDropdown" minWidth="155" change="handleUnitDropdownChange(event)"/>
</s:HGroup>
and i m trying to hide the hgroups on a condition when this bean tagInfoData have a value "notworking" otherwise it will shown..
should i need to write code in the creation complete as all this is in a pop up window of the button click event
i m using this
if(tagInfoData.selectionType.match("notworking"))
{
Scale.visible=true;
Precision.visible=true;
Units.visible=true;
}
else
{
Scale.visible=false;
Precision.visible=false;
Units.visible=true;
}
In each of the HGroups you want to hide, add visible="{myFunc(tagInfoData)}"
Then define:
internal function myFunc(tagInfoData:whateverTypeItIs):Boolean{
return ! tagInfoData.selectionType.match("notworking")
}
Make sure tagInfoData is defined as [Bindable]

Flex 4.5, alignment of form helpcontent messed up

When first entering the world of Flex form components,
I noticed it was very easy to create a nice looking form in a matter of minutes.
However, when I supplied a helpcontent component to each form component, my formlayout is messed up. The helpcontent goes over my form components, I tried everything, but I just can't get it to align as it should.
Here is a picture:
http://gyazo.com/7363fb80c70340e029e41165b36bed2c.png
And here is the code:
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%">
<s:Group width="100%" height="100%" left="10" right="10" top="10" bottom="10">
<s:VGroup width="100%" height="100%">
<s:HGroup width="100%" height="50%">
<s:Form width="75%">
<s:layout>
<s:FormLayout/>
</s:layout>
<s:FormHeading label="Filter (Optioneel)" />
<s:FormItem label="Naam:" width="100%">
<s:TextInput id="txtName" width="200"/>
<s:helpContent>
<s:Label x="0" y="0" paddingLeft="0" paddingRight="0"
text="Vul hier een naam in, dit mag een deel zijn."/>
</s:helpContent>
</s:FormItem>
<s:FormItem label="Datum vanaf:" width="100%">
<mx:DateField id="dtFrom" width="200"/>
<s:helpContent>
<s:Label text="Kies hier een startdatum."/>
</s:helpContent>
</s:FormItem>
<s:FormItem label="Datum tot:" width="100%">
<mx:DateField id="dtTo" width="200"/>
<s:helpContent>
<s:Label text="Kies hier een einddatum."/>
</s:helpContent>
</s:FormItem>
</s:Form>
</s:HGroup>
<s:Panel width="100%" height="100%">
<mx:AdvancedDataGrid id="dgRunningQuotations" left="5" right="5"
top="5" bottom="25"
designViewDataType="flat"
resizableColumns="false" textAlign="right"
variableRowHeight="true">
<mx:columns>
<mx:AdvancedDataGridColumn width="50" dataField="ID"
headerText="NR"/>
<mx:AdvancedDataGridColumn dataField="Name" headerText="Naam"
wordWrap="true"/>
<mx:AdvancedDataGridColumn width="100" dataField="PDate"
headerText="Datum"/>
</mx:columns>
</mx:AdvancedDataGrid>
</s:Panel>
</s:VGroup>
</s:Group>
</s:Group>
Increasing the form size to an absolute value instead of 75%, doesn't help either.
Try not adding the width property on your form items and maybe even the items within that as see if that works. I tried a very simple example with no position settings and it worked fine.

Flex Spark: How to right align an icon on a button or tabbar button?

I would like to right align an icon on a button or tabbarbutton and keep the text left aligned in Flex 4.0 Spark.
So far, I've come up with something like the following in my custom skin:
<s:HGroup>
<s:HGroup horizontalAlign="left">
<s:Label id="labelDisplay"
textAlign="left"
maxDisplayedLines="1"
top="10">
</s:Label>
</s:HGroup>
<s:HGroup horizontalAlign="right" bottom="5" right="0">
<s:BitmapImage source="#Embed('assets/images/icons/close.png')" />
</s:HGroup>
</s:HGroup>
But it seems silly to have an HGroup with 2 HGroup children just to get the horizontalAlign to the right.
Anyone know of a better way?
Thx,
=Dave
You could set the width of the label to be 100%.
<s:HGroup>
<s:Label id="labelDisplay" width="100%"/>
<s:BitmapImage source="#Embed('assets/images/icons/close.png')" />
</s:HGroup>
If your buttons are all an explicit width, you could also try something like this:
<s:HGroup>
<s:Label id="labelDisplay"/>
<mx:Spacer width="100%"/>
<s:BitmapImage source="#Embed('assets/images/icons/close.png')" />
</s:HGroup>

Resources