0

Problem carriage return with tooltip

asked 2010-06-28 05:06:34 +0800

SHERKHAN gravatar image SHERKHAN
231 3

Hi all

I have a problem with the carriage return in tooltip.

My code :

return new ListitemRenderer() {

            @Override
            public void render(Listitem item, Object data) throws Exception {
                item.setValue(data);
                Listcell cell = new Listcell();
                item.appendChild(cell);
                Hbox box = new Hbox();
                cell.appendChild(box);

                        [...]

                 toolTip += fieldName + " : " + result + "\n" + "something";

                 Label label = new Label(extension);
                 label.setTooltiptext(toolTip);
                 box.appendChild(label);
            }
        };

And the "\n" is not interpreted...

Thanks for your help,

Regards,

SHERKHAN

delete flag offensive retag edit

19 Replies

Sort by ยป oldest newest

answered 2010-06-28 07:39:57 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2010-06-28 07:42:38 +0800

a typo ??

toolTip += fiel...


String toolTip = "Long Text " + "\n" + "in two lines works for me";
btnHelp.setTooltiptext(toolTip);

Works perfect for me with 5.0.2

link publish delete flag offensive edit

answered 2010-06-28 08:07:54 +0800

SHERKHAN gravatar image SHERKHAN
231 3

Thanks Stephan,

but when I did

System.out.println(label.getTooltiptext());
, the "\n" exist... I don't understand... I am using the 3.6.3.

link publish delete flag offensive edit

answered 2010-06-28 10:30:58 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2010-06-28 10:33:12 +0800

Hmmmmm, runs by me too in 3.6.3.

on startup

		String toolTip = "Long Text " + "\n" + "in two lines works for me";
		btn100.setTooltiptext(toolTip);
		System.out.println(btn100.getTooltiptext());

.
2010-06-28 17:28:57,341 DEBUG   InitApplicationCtrl M[onCreate$startWindow] - --> [ForwardEvent onCreate$startWindow <InitApplicationCtrl startWindow>]
2010-06-28 17:28:57,786 INFO    ServiceLogging M - Execution time: 2ms CommonService.getAllTablesRecordCounts()
Long Text 
in two lines works for me


an encoding problem?? I use UTF-8

link publish delete flag offensive edit

answered 2010-06-29 03:28:12 +0800

SHERKHAN gravatar image SHERKHAN
231 3

Hi Stephan,

I use UTF-8 too... grrrr

Here is my entire code :

return new ListitemRenderer() {

            @Override
            public void render(Listitem item, Object data) throws Exception {
                item.setValue(data);
                Listcell cell1 = new Listcell(((Wikitty) data).getId());
                Listcell cell2 = new Listcell();
                item.appendChild(cell1);
                item.appendChild(cell2);
                Collection<String> extensions = ((Wikitty) data).getExtensionNames();
                Iterator<String> itCurrent = extensions.iterator();
                while (itCurrent.hasNext()) {
                    String extension = itCurrent.next();
                    String toolTip = getToolTipsByExtension(extension, (Wikitty) data); // toolTip has "\n"
                    if (itCurrent.hasNext()) {
                        extension += ", ";
                    }
                    Label label = new Label(extension);
                    label.setTooltiptext(toolTip);
                    cell2.appendChild(label);
                }
            }
        };

and my zul file part:

<groupbox>
        <caption label="wikitties" />
        <listbox id="wikittiesListBox" rows="8" model="@{win$composer.wikittyModel}" itemRenderer="@{win$composer.wikittyRenderer}" selectedItem="@{win$composer.selectedWikitty}">
        <listhead sizable="true">
            <listheader label="ID" />
            <listheader label="Extensions" />
        </listhead>
        </listbox>
        <button id="delete" label="Delete" width="46px" height="24px"/>
    </groupbox>

Maybe I do something bad...

link publish delete flag offensive edit

answered 2010-06-30 20:19:02 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

Hi SHERKHAN
Is it not work if you set below string ?

String toolTip = "Long Text " + "\n" + "in two lines works for me";

link publish delete flag offensive edit

answered 2010-07-01 02:47:05 +0800

SHERKHAN gravatar image SHERKHAN
231 3

Hi Jimmy

I tried with this example but it doesn't work... In fact I tried with whatever zk elements but the "\n" are not displayed. The result is always : "Long Textin two lines works for me". Just one line... And I tried with the 5.0.2, nothing changed... RHAAAA what is wrong with me?! I use tomcat and firefox.

Thanks for your help,

SHERKHAN

link publish delete flag offensive edit

answered 2010-07-02 01:34:21 +0800

603424 gravatar image 603424
127 3

try replacing "\n" with "\\n" or "\\\\n"

link publish delete flag offensive edit

answered 2010-07-02 03:31:11 +0800

SHERKHAN gravatar image SHERKHAN
231 3

Thanks 603424 for your help but it doesn't work...

I don't understand why a simple thing doesn't work!

Regards,

SHERKHAN

link publish delete flag offensive edit

answered 2010-07-02 05:07:08 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2010-07-02 05:34:56 +0800

Have a look on your first loaded page (I work with only ONE page 'index.zul' and Borderlayout Center area for the changed content)

I have the next line in my index.zul file after the <page ....> definition.

<?meta content="text/html; charset=UTF-8" pageEncoding="UTF-8"?>

best
Stephan

link publish delete flag offensive edit

answered 2010-07-02 07:39:30 +0800

SHERKHAN gravatar image SHERKHAN
231 3

updated 2010-07-02 07:45:24 +0800

Hi Stephan,

Thanks for your help but It doesn't still work... I'm desperate!
Here is my entire zul page (maybe you will find out the mistake...):

<?xml version="1.0" encoding="UTF-8"?>
<?page title="wikitties" contentType="text/html;charset=UTF-8"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>

<window id="win" title="wikitty" width="800px" border="normal" apply="org.nuiton.wikitty.ui.WikittyController">

    Search: <textbox id="Search" />
    <toolbarbutton id="home" label="Select another proxy"/>
    <listbox autopaging="true" mold="paging" id="extensionListBox" rows="5" model="@{win$composer.extensions}"
    selectedItem="@{win$composer.selectedExtension}">

        <listhead>
            <listheader label="Name" />
            <listheader label="Version" />
        </listhead>

        <listitem self="@{each='extension'}">
            <listcell label="@{extension.name}" />
            <listcell label="@{extension.version}" />
        </listitem>

    </listbox>

    <groupbox>
        <listbox autopaging="true" mold="paging" id="wikittiesListBox" multiple="true" rows="10" model="@{win$composer.wikittyModel}" itemRenderer="@{win$composer.wikittyRenderer}" selectedItem="@{win$composer.selectedWikitty}">
        <listhead sizable="true">
            <listheader label="ID" />
            <listheader label="Extensions" />
        </listhead>
        </listbox>
        <button id="delete" label="Delete" height="24px"/>
    </groupbox>

    <groupbox>
        <caption label="extensions" />
        <listbox id="formListBox" model="@{win$composer.wikittyForm.formModel}" rows="7" itemRenderer="@{win$composer.wikittyForm.fieldExtensionRenderer}">
            <listhead sizable="true">
                <listheader label="Extension" />
                <listheader label="Type" />
                <listheader label="Content" />
            </listhead>
        </listbox>
        <button id="add" label="Add" height="24px"/>
        <button id="update" label="Update" height="24px"/>
        <button id="addNewInput" label="New input" height="24px" />
        <button id="deleteInput" label="Delete input" height="24px" />

        <listbox id="newExtension" rows="1" mold="select" model="@{win$composer.extensions}" selectedItem="@{win$composer.selectedNewExtension}">
            <listitem self="@{each='newExtension'}">
                <listcell label="@{newExtension.name}"/>
            </listitem>
        </listbox>
        <button id="addNewExtension" label="Add extension" height="24px" />
    </groupbox>

</window>

Thanks for your help,

Best regards,

SHERKHAN

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

Asked: 2010-06-28 05:06:34 +0800

Seen: 1,130 times

Last updated: Dec 13 '18

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More