-
FEATURED COMPONENTS
First time here? Check out the FAQ!
HTML support in Label or label-like component?
Think about these:
1. Display spaces by setting label of Listitem to " " to achieve text padding (Listbox.mold='select')
2. Display copyright or other special characters by setting value/label of Label/LabelElement/etc to "©"
Can't achieve those in the following sample code:
<?xml version="1.0" encoding="UTF-8"?> <zk> <textbox id='tb' multiline='true' width='100%' rows='10'/> <button label='Fill with these text' onClick='SetLabel()'/> <separator/> Listitem: <listbox id='lb' mold='select'/> <separator/> Label: <label id='l' value='a label is here'/> <separator/> Html: <html id='ht' content='a html is here'/> <zscript> <![CDATA[ String sInitLines= "Can you see 1+ spaces between the following brackets? [ ]\n" + "Can you see a copyright character? [©]\n" + " 1 TRACE TRACE log level\n" + " 10 INFO INFO log level\n" + " 100 WARNING WARNING detail log level\n" + "1000 ERROR ERROR log level\n" + "...1...TRACE.......TRACE.log.level\n" + "..10...INFO........INFO.log.level\n" + ".100...WARNING.....WARNING.detail.log.level\n" + "1000...ERROR.......ERROR.log.level\n" + ""; tb.setValue (sInitLines); public void SetLabel () { lb.getChildren().clear(); String sLines = tb.getValue(); java.io.LineNumberReader lnr = new java.io.LineNumberReader (new java.io.StringReader(sLines)); while (true) { String sLine = lnr.readLine (); if (sLine == null) break; if (lnr.getLineNumber() == 1) { l.setValue (sLine); ht.setContent (sLine); } Listitem li = new Listitem (sLine); lb.appendChild (li); } lnr.close(); } ]]> </zscript> </zk>
Padding can be achieved trough using z-class
.mylabel { padding: 1 1 1 1; }
It is unclear how to set as label value
<label zclass="mylabel" id="descriptionLabel" style="color: red" value="\u00A0" />
does not work
Hey Stas283,
You need to set the pre property of the label.
<label pre="true" value=" "/>
This will then preserve white space in the value. The equivalent javadoc is here.
You can do that here's an example :
<zk xmlns:h="http://www.w3.org/1999/xhtml">
<h:div class="z-toolbarbutton-cnt">
Hello
<h:b> THIS MUST BE BOLD </h:b>
Here goes normal
</h:div>
</zk>
you just need to set proper class of the HTML DIV. I your case class will be different.
Asked: 2010-01-22 02:08:16 +0800
Seen: 2,606 times
Last updated: Apr 11 '12