Captive Imagination
July 31, 2010, 11:49:41 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Hosting change completed. Please send an e-mail to support@captiveimagination.com if you have any problems.
 
   Home   Help Search Calendar Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: TextArea.getText()  (Read 2216 times)
0 Members and 1 Guest are viewing this topic.
syam
Full Member
***
Offline Offline

Posts: 139


View Profile
« on: September 13, 2008, 03:43:26 AM »

TextArea with setWordWrap(false) replaces all '\n' with '\r' if we edit the text. If the text is not edited, then, it is not affected this way.
Test code:
(Click 'Show' button before editing and see the positions of '\n' and '\r'. Do it again after editing and watch the values.)
Also, this effect is not there if setWordWrap(false) line is commented out.
Code:
package test;

import org.jseamless.*;
import org.jseamless.container.*;
import org.jseamless.event.*;
import org.jseamless.style.*;

public class Test extends Application {
   
    public Test() {
        super("Test");
        addWindow(new TWindow());
    }
   
    class TWindow extends Window {
       
        public TWindow() {
            super("TextArea Test");
            TextArea text = new TextArea();
            text.setWordWrap(false);
            text.setText("This is the initial text.\nAnd, this is the second line.");
            add(text);
            add(new HorizontalBox(text));
        }
    }
   
    class HorizontalBox extends Box implements EventListener {
       
        private Label display;
        private TextArea text;
       
        public HorizontalBox(TextArea text) {
            super();
            this.text = text;
            setLayout(Layout.HORIZONTAL);
            setHorizontalSpacing(5);
            Button b = new Button("Show");
            b.addEventListener(this);
            add(b);
            add(display = new Label(""));
        }
       
        public void eventOccurred(Event e) {
            if(e.getType() == EventType.CLICK) {
                display.setText("\\n @ " + text.getText().indexOf('\n') + " and \\r @ " + text.getText().indexOf('\r'));
            }
        }
    }
}
Logged
darkfrog
Administrator
Inspired Imagination
*****
Offline Offline

Posts: 2650


View Profile
« Reply #1 on: September 13, 2008, 08:59:45 AM »

Though that kinda sucks....unfortunately that is the way Flex deals with it internally.  I could re-write it and probably will eventually, but right now it's just utilizing exactly what Flex utilizes.
Logged
syam
Full Member
***
Offline Offline

Posts: 139


View Profile
« Reply #2 on: September 13, 2008, 10:55:40 AM »

OK. For the time being, I will deal with it in my code.
This means, I should be careful if I use an implementation other than Flex.
Thanks
Logged
syam
Full Member
***
Offline Offline

Posts: 139


View Profile
« Reply #3 on: December 17, 2008, 06:37:42 PM »

Issue #5 is logged for this and issues related to TextArea.
Logged
darkfrog
Administrator
Inspired Imagination
*****
Offline Offline

Posts: 2650


View Profile
« Reply #4 on: December 17, 2008, 07:20:52 PM »

Thanks. Smiley
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.182 seconds with 20 queries.