nihavend opened a new issue #598: TextArea is not functioning properly in popup
URL: https://github.com/apache/royale-asjs/issues/598
 
 
   Here is the test case for the popup to display xml text.
   
   ```
   <?xml version="1.0" encoding="utf-8"?>
   <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"
                           creationComplete="loadData()"
                           height="100%"
                           width="100%"
                           >    
        
        <fx:Metadata>
        </fx:Metadata>
        
        <fx:Script>
                <![CDATA[
                        //  xmlns:local="*"
                        
                        import mx.managers.PopUpManager;
                        import mx.core.IUIComponent;
                        
                        private var fileViewWindow:FindBugFileViewPopup;
                                        
                        
                        public function loadData():void {
                                
                        }
   
                        public function closePopup():void {
                                PopUpManager.removePopUp(fileViewWindow);
                        }
                        
                        
                        public function onClick():void {
                                
                                var fileTag:String = "infotag=myraConfig"
                                fileViewWindow = PopUpManager.createPopUp(this 
as IUIComponent, FindBugFileViewPopup, true) as FindBugFileViewPopup;
                                //var fileViewWindow:FileViewPopup = new 
FileViewPopup();
                                fileViewWindow.isNativeXML = true;
                                fileViewWindow.fileTag = fileTag; //"joblog=" + 
jobDetailLocalXml.@Id;
                                //PopUpManager.addPopUp(fileViewWindow, 
parentApplication as mx.core.IUIComponent, true);
                                fileViewWindow.initService("DEMO");
                                PopUpManager.centerPopUp(fileViewWindow);
                                fileViewWindow.setFocus();
                                
                        }
                        
                ]]>
        </fx:Script>
        
        <fx:Declarations>               
                <fx:XMLList id="PInaraData">
                        <list title="Grup Listesi" id="0">
                                <jobGroup title="Independents" id="-1">
                                        <jobProperty title="SENSORDATA_HOURLY" 
id="1" statu="0" port="1"/>
                                        <jobProperty title="SENSORDATA_DAILY" 
id="2" statu="0" port="1"/>
                                        <jobProperty 
title="SENSORDATA_ALWAYSON" id="3" statu="0" port="1"/>
                                        <jobProperty 
title="SENSORDATA_FIVE_MIN" id="4" statu="9" port="1"/>
                                        <jobProperty 
title="PERSONAL_PROFILE_INFO" id="5" statu="9" port="1"/>
                                        <jobProperty 
title="SENSORDATA_AVG_CONS" id="6" statu="9" port="1"/>
                                </jobGroup>
                        </list>
                </fx:XMLList>
        </fx:Declarations>      
        
        <s:layout>
                <s:VerticalLayout gap="10" paddingRight="10" paddingLeft="10" 
paddingTop="10" paddingBottom="20" />
        </s:layout>
        
        <mx:Panel title="Tree Label Function Example"
                          paddingBottom="10" paddingTop="10" paddingLeft="10" 
paddingRight="10"
                          height="50%" width="50%">
                
                <s:Button id="TwoNode" click="onClick()"  label="Show Popup"/>
                <s:Button id="close" click="closePopup()"  label="Close Popup"/>
                
                <s:TextArea height="100%" width="50%" text="Selected Item: 
selectedNode.@label"/>
        </mx:Panel>
        
   </s:Application>
   ```
   
   
   ```
   <?xml version="1.0"?>
   <s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009";
                           xmlns:mx="library://ns.apache.org/royale/mx" 
                           xmlns:s="library://ns.apache.org/royale/spark"
                           close="handleCloseEvent()"
                           keyDown="titleWindow_keyDown(event);"
                           
creationComplete="titlewindow1_creationCompleteHandler(event)"
                           width="800" height="500">
        
        <s:layout> 
                <s:BasicLayout/>
        </s:layout>
        
        <fx:Script>
                <![CDATA[
   
                        import mx.controls.Alert;
                        import mx.events.CloseEvent;
                        import mx.events.KeyboardEvent;
                        import mx.events.FlexEvent;
                        import mx.managers.PopUpManager;
                        import mx.resources.ResourceManager;
                        import mx.rpc.events.FaultEvent;
                        import mx.rpc.events.ResultEvent;
                        
                        import mx.core.Keyboard;
                        // import flash.ui.Keyboard;
                        
                        import spark.layouts.HorizontalLayout;
                        
                        // import 
flashx.textLayout.compose.StandardFlowComposer;
                        import 
org.apache.royale.textLayout.compose.StandardFlowComposer;
                        // import flashx.textLayout.conversion.TextConverter;
                        import 
org.apache.royale.textLayout.conversion.TextConverter;
                        import org.apache.royale.textLayout.elements.TextFlow;
                        
                        protected var oldSearchResult:int = 0;
                        protected var vScrollPos:int = 0;
                        
                        private var _isNativeXML:Boolean = false;
                        public function get isNativeXML():Boolean
                        {
                                return _isNativeXML;
                        }
                        public function set 
isNativeXML(isNativeXML:Boolean):void
                        {
                                _isNativeXML = isNativeXML;
                        }
                        
                        private var _fileTag:String;
                        public function get fileTag():String
                        {
                                return _fileTag;
                        }
                        public function set fileTag(fileTag:String):void
                        {
                                _fileTag = fileTag;
                        }
                        
                        private var titlePrefix:String = 
ResourceManager.getInstance().getString('messages', 'logViewWindowTitle');
                        
                        [Bindable]      
                        private var defEndOff:int = 5000;
                        
                        private var logViewCTX:String = "/logview";
                        
                        private function 
titleWindow_keyDown(evt:mx.events.KeyboardEvent):void {
                                COMPILE::SWF {var charCode:uint = evt.charCode;}
                                COMPILE::JS {var charCode:uint = evt.keyCode;}  
                                
                                if (charCode == Keyboard.ESCAPE) {
                                        this.dispatchEvent(new 
mx.events.CloseEvent(mx.events.CloseEvent.CLOSE));
                                }
                        }
                        
                        public function initService(url:String = null):void {
                                trace(url);
                                xmlService_resultHandler();
                        }
                        
                        private function refreshService(event:Event):void {
                                // Alert.show("EndOff : " + endOff.value);
                                // var url:String = 
"http://127.0.0.1:3000/logdetail"; + "?" + "fname=" + fileTag + "&" + 
"beginoff=" + beginOff.value + "&" + "endoff=" + endOff.value;
                                var url:String = logViewCTX + "?" + fileTag + 
"&" + "beginoff=" + beginOff.value + "&" + "endoff=" + endOff.value;
                                //Alert.show("service url : " + url);
                                initService(url);
                                defEndOff = endOff.value;
                        }
   
                        protected function 
titlewindow1_creationCompleteHandler(event:FlexEvent):void {
                                // addEventListener(MouseEvent.CLICK, 
handleClickEvent);
                                title = titlePrefix;
                                //initService();
                        }
                        
                        private function handleClickEvent(event:Event):void {
                                // Alert.show("event.type : " + event.type + " 
Target : " + event.target);
                        }
                        
                        private function handleCloseEvent():void {
                                PopUpManager.removePopUp(this);
                        }
                        
                        private function 
errAlert(eventObj:mx.events.CloseEvent):void {
                                handleCloseEvent();
                        }
                        
                        protected function 
xmlService_faultHandler(event:FaultEvent):void {
                                Alert.show(event.toString(), "Hata oluştu !");
                                handleCloseEvent();
                        }
                        
                        protected function xmlService_resultHandler():void {
                                
                                var returnXml:XML;
                                var returnTxt:String = null;
                                
                                
                                returnXml = <return>
                                                          <code>0</code>
                                                          <message>
                                                                <data>
                                                                  <meta>
                                                                        
<size>461</size>
                                                                        
<name>conf\myraConfig.xml</name>
                                                                  </meta>
                                                                  <content>
                                                                        
<myraConfig xmlns="http://www.likyateknoloji.com/myra-config";>
                                                                          
<persistent>false</persistent>
                                                                          
<normalize>true</normalize>
                                                                          
<frequency>1</frequency>
                                                                          
<higherThreshold>10</higherThreshold>
                                                                          
<lowerThreshold>3</lowerThreshold>
                                                                          
<logPath>./</logPath>
                                                                          
<usejobnamesforlog>NO</usejobnamesforlog>
                                                                          
<logFileExt>.log</logFileExt>
                                                                          
<globalLogPath>./</globalLogPath>
                                                                          
<logbuffersize>2000</logbuffersize>
                                                                          
<logpagesize>10</logpagesize>
                                                                        
</myraConfig>
                                                                  </content>
                                                                </data>
                                                          </message>
                                                        </return>;
                                
                                if(returnTxt != null) {
                                        
Alert.show(resourceManager.getString("messages", 
"fileViewPopDataFileCorrupted"));
                                        mainTextField.textFlow = 
TextConverter.importToFlow(returnTxt, TextConverter.PLAIN_TEXT_FORMAT) as 
TextFlow;
                                        callLater(updateEndOff);
                                } else if(returnXml.code == "-99" || 
returnXml.code == "-1") {
                                        Alert.show("" + 
returnXml.message.substr(0, 200) + "...", "Hata oluştu kod[" + returnXml.code + 
"]", Alert.OK, this, errAlert, null);
                                } else {
                                
                                        var result:XML = 
XML(returnXml.message.data);
                                        
                                        this.title = titlePrefix + " : " + 
XML(result).meta.name;
                                        var fSize:int =  XML(result).meta.size;
                                        
                                        fileSize.text = fSize + "K";
                                        beginOff.maximum = fSize -1;
                                        endOff.maximum = fSize;
                                        if(isNativeXML) {
                                                mainTextField.textFlow = 
TextConverter.importToFlow((XML(result.content).children()[0]).toString(), 
TextConverter.PLAIN_TEXT_FORMAT) as TextFlow;
                                        } else {
                                                mainTextField.textFlow = 
TextConverter.importToFlow(String(XML(result).content), 
TextConverter.PLAIN_TEXT_FORMAT) as TextFlow;
                                        }
                                        callLater(setLineNumbers);
                                        callLater(updateEndOff);
                                }
                        }
                        
                        protected function 
button1_clickHandler(event:MouseEvent):void {
                                
                                var searchStr : String = searchTxt.text;
                                var truncatedText : String;
                                
                                truncatedText = 
mainTextField.text.substring(oldSearchResult);
                                
                                
                                var searchResult:int = 
truncatedText.search(searchStr);
                                
                                mainTextField.setFocus();
                                
                                if(searchResult != -1) {
                                        
                                        var bIdx:int = oldSearchResult + 
searchResult;
                                        var eIdx:int = oldSearchResult + 
searchResult + searchStr.length;
                                        var pos:int =  
mainTextField.selectionActivePosition;
                                        
                                        mainTextField.selectRange(bIdx, eIdx);
                                        oldSearchResult = eIdx;
                                        mainTextField.scrollToRange(bIdx, 
oldSearchResult);
                                
                                        setCaretPos();
                                        setLineNumbers();
                                } else {
                                        
Alert.show(resourceManager.getString("messages", "fileViewPopNoMoreResult"));
                                }
                                
                        }
   
                        protected function 
mainTextField_clickHandler(event:MouseEvent):void {
                                
                                var caretPos:int = 
mainTextField.selectionActivePosition;
                                
                                if(event.target is Button) {
                                        
                                        if(event.type == MouseEvent.CLICK) {
                                                // vScrollPos = 
mainTextField.scroller.verticalScrollBar.value;
                                                //scrollBarPosLabel.text = "[" 
+ mainTextField.scroller.verticalScrollBar.value + "]-[" + vScrollPos + "]";
                                        }
                                } else {
                                        oldSearchResult = caretPos;
                                        setCaretPos();
                                        setLineNumbers();
                                }
                        }
                        
                        protected function setCaretPos():void {
                                activePosition.text = "[" + 
mainTextField.selectionActivePosition + "]";
                        }
                        
                        protected function setLineNumbers():void {
                                var flowComposer : StandardFlowComposer = 
StandardFlowComposer(mainTextField.textFlow.flowComposer);
                                var absoluteIndex : int = 
mainTextField.selectionActivePosition;
                                var lineIdx : int = 
flowComposer.findLineIndexAtPosition(absoluteIndex);
                                lineNumbers.text = (lineIdx + 1) + "/" + 
mainTextField.textFlow.numChildren;
                                //endOff.value = 5000;
                        }
                        
                        protected function updateEndOff():void {
                                endOff.value = defEndOff;
                                // Alert.show("endOff.value : " + endOff.value);
                        }
                        
                ]]>
        </fx:Script>
        
        <fx:Declarations>
        </fx:Declarations>
        
        <s:VGroup left="5" right="10" top="10" bottom="10" height="100%" 
width="100%">
   
                <mx:HBox horizontalAlign="center">
                        <s:FormItem 
label="{resourceManager.getString('messages', 'initialOffset')}" layout="{new 
HorizontalLayout()}" width="100%" >
                                <s:NumericStepper id="beginOff" stepSize="1" 
width="100" minimum="0" maximum="999999999" />
                        </s:FormItem>
                        <s:FormItem 
label="{resourceManager.getString('messages', 'endOffset')}" layout="{new 
HorizontalLayout()}" width="100%" >
                                <s:NumericStepper id="endOff" stepSize="1" 
width="100" minimum="0" maximum="999999999" value="{defEndOff}"/>
                        </s:FormItem>
                        <s:FormItem width="100%" >
                                <s:Button 
label="{resourceManager.getString('messages', 'refresh')}" 
click="refreshService(event as Event)" />
                        </s:FormItem>
                </mx:HBox>
                
                <mx:HRule width="100%" />
                
                <s:FormItem label="{resourceManager.getString('messages', 
'searchTextLabel')}" layout="{new HorizontalLayout()}" width="100%" >
                        <s:TextInput id="searchTxt" text="fname" />
                        <s:Button label="{resourceManager.getString('messages', 
'searchNextButLabel')}" click="button1_clickHandler(event)" />
                </s:FormItem>
                
                <s:Line width="100%">
                        <s:stroke>
                                <s:SolidColorStroke color="0x000000" weight="1" 
caps="square"/>
                        </s:stroke>
                </s:Line>
                
                <!--s:TextArea  id="mainTextField" verticalScrollPolicy="on" 
width="100%" height="100%" click="mainTextField_clickHandler(event)" 
editable="false" skinClass="com.likya.pinara.skins.TextAreaLineNumbersSkin" /-->
                <s:TextArea  id="mainTextField" verticalScrollPolicy="on" 
width="100%" height="100%" click="mainTextField_clickHandler(event)" 
editable="false"/>
   
                <s:BorderContainer height="25" width="100%" 
backgroundColor="0xDCDCDC" borderStyle="solid">
                        <s:layout>
                                <s:HorizontalLayout paddingLeft="5" 
paddingRight="5" paddingTop="5" paddingBottom="5" verticalAlign="middle"/>
                        </s:layout>
                        <s:Label text="{resourceManager.getString('messages', 
'lineNumbersLabel')}" />
                        <s:Label id="lineNumbers" />
                        <s:Spacer width="5%" />
                        <s:Label text="{resourceManager.getString('messages', 
'caretPositionLabel')}" />
                        <s:Label id="activePosition" text="[0]" />
                        <s:Spacer width="100%" />
                        <s:HGroup horizontalAlign="right">
                                <s:Label 
text="{resourceManager.getString('messages', 'fileSizeLabel')}" />
                                <s:Label id="fileSize" right="0" />
                        </s:HGroup>
                </s:BorderContainer>
        </s:VGroup>
                
   </s:TitleWindow>
   
   ```
   
   

----------------------------------------------------------------
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