create an empty line between text

3 messages - 911 views

Hi!

I've created an own widget that displays text & pictures in it. It works fine, but I can't display an empty line.

for example:

this is line 1

 

between this and line 2 is an empty line

 The empty line is not shown in my application.

 

 All I've done is read line after line. For each line I create a TextArea Widget and add it to the children.

 TextArea t = new TextArea();
  t.setText( line );
  t.parseAuthorStyle("align:fill-left;");
  add(t);

If I find a linebreak ('\n') I add an BREAK_WIDGET_TAG-Widget.

add( new Widget( KuixConstants.BREAK_WIDGET_TAG ) );

 This works as long there is only one linebreak. If there are two linebreaks in series, only one linebreak is visible.

 

The textarea has the same problem as my widget. If I use the following xml tag, only one <br/> is visible.

<textarea styled="true">

  <![CDATA[A simple sentence with <b>bold</b>, <i>italic</i>,<br/><br/><u>underlined</u> text.]]>

</textarea>

 

 How it looks like:

 A simple sentence with bold, italic,

underlined text.

 

How it should look like:

simple sentence with bold, italic,

 

underlined text.

If I add a single character between two linebreaks the lost line becomes visible. This means the line is available but I think it has a height of 0.

 

Do you have any idea how I can fix this to get an emtpy line without showing any character? ' ' doesn't work here.

 

Thx!!!

Stefan

Hmm ... the problem come from that the textare use the FlowLayout to render each word as a separate widget. And then the FlowLayout assume that a break widget has a null size.

Does your custom widget extends Textare ? Else you can split the text en break return into several sub textarea en add a gap spacing between each one.

It doesn't extend Textarea, because it does not have an public constructor that takes a tag-String as parameter.

My class just extends Widget. It doesn't need anything else.

I've solved my problem by adding a min-size attribute to the BREAK-widget. As i set this attribute from java code I can set the min-height to Font.getDefault().getHeight().

 

It would be great if it would be possible to extend Textarea and add own tag definitions to it. Currently all currently supported tags are getting lost when you extend TextArea-Widget.

 

Sincerely

Stefan