nihavend commented on issue #797: Strange behavior of form item due to label 
retrieved from resource
URL: https://github.com/apache/royale-asjs/issues/797#issuecomment-615285104
 
 
   @aharui
   
   I debugged the code at the bottom an here are the results :
   
   this function calculates the width
   ```
   mx.containers.FormItem.prototype.commitProperties = function() {
     mx.containers.FormItem.superClass_.commitProperties.apply(this);
     if (this.mx_containers_FormItem_labelChanged) {
       this.mx_containers_FormItem_labelObj.text = this.label;
       this.mx_containers_FormItem_labelObj.validateSize();
       this.mx_containers_FormItem_labelChanged = false;
     }
   };
   ```
   
   This method is visited 7 times
   
   1. for userName1 label, labelChange is false
   2. for userName1 label, labelChange is false
   3. for password1 label, label changed is true, label = "Şifre"
   4. for password1 label, label changed is false
   5. for div.Container.FormItem, label changed is false
   6. for div.Container.FormItem, label changed is false
   7. for userName1 label, labelChange is true, label = "Kullanıcı Adı"
   
   I guess the when the method 
mx.containers.FormItem.prototype.commitProperties is called, the first label is 
not initialized yet because it is getting text from resources and as the 
calculation is done in the first pass the width is wrongly - mean the for the 
second label, "password1" is set at that time - calculated due to empty first 
label.
   
   This is some kind of sequence of timing issue. I could not investigate the 
root cause.
   
   Here is the source :
   
   ```
   
   <?xml version="1.0" encoding="latin5" ?>
   
   <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
                           xmlns:s="library://ns.apache.org/royale/spark"
                           xmlns:mx="library://ns.apache.org/royale/mx"
                           height="600" width="800"
                           >
        <fx:Metadata>
                [ResourceBundle("messages")]
        </fx:Metadata>
        
        <s:Group width="288" height="179">
                
                <s:layout>
                        <s:VerticalLayout gap="10" paddingRight="10" 
paddingLeft="10" paddingTop="10" paddingBottom="20" />
                </s:layout>
                
                <s:Panel
                        horizontalCenter="0"
                        verticalCenter="0"
                        id="loginPanel1" 
                        width="288" 
                        height="179" 
                        chromeColor="#E2E5E7"
                        title="{resourceManager.getString('messages', 
'loginTitle')}" 
                        >
                        
                        <mx:Form id="main_form1" width="100%" height="100%" 
top="10" left="5"><!-- defaultButton="{button}" -->
                                
                                <mx:FormItem id="id_userName1" 
label="{resourceManager.getString('messages', 'userName')}"> 
                                        <s:TextInput id="userName1"/>
                                </mx:FormItem>
                                
                                <mx:FormItem id="id_password1" label="Sifre">
                                        <s:TextInput id="password1" 
displayAsPassword="true"/>
                                </mx:FormItem>
                                
                                <<mx:FormItem>
                                        <s:Button id="button1" width="64" 
label="{resourceManager.getString('messages', 'login')}"/>
                                </mx:FormItem>
                        </mx:Form>              
                        
                </s:Panel>
                
        </s:Group>
        
   </s:Application>
   
   
   ```
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to