Jump to content

Max length on a panel of tunistatusbar


delagoutte

Recommended Posts

i have a status bar with X panels.

the first panel width is set to 200px

if the text on my firstpanel is longer than 200px, it is write over the second panel.

post-892-0-83475200-1535989804_thumb.png

what can i do for having "..." in the end of text and having the full value in the hint ?

 

 

Link to comment
Share on other sites

Hi,

 

Maybe something like this, can you try?

 

UniStatusBar -> ClientEvents -> UniEvents ->

function beforeInit(sender, config)
{
    config.defaults = {
        style: 'overflow:hidden; text-overflow:ellipsis;',
        listeners: {
            afterrender: function(item) {
                var tm = new Ext.util.TextMetrics();
                new Ext.tip.ToolTip({
                    target: item,
                    html: item.text,
                    listeners: {
                        beforeshow: function updateTipBody(tip) {
                            if (item.getWidth() < (tm.getSize(item.text).width) + 5) {
                                tip.update(item.text);
                            } else {
                                return false;
                            }
                        }
                    }
                });
            }
        }
    };

}
Link to comment
Share on other sites

with this code

UniStatusBar1.Panels[1].Text :=
'long text long text long text long text long text';

that is not the property item.text that is modified (it keep the initial value), there is a new property item.html that is created with this new value.

 

a unigui bug ?

 

So for my problem i fixe it with a patch like this :

if (item.html){
                                tip.update(item.html);
                          }
                          else
                          {
                            tip.update(item.text);
                          }
Link to comment
Share on other sites

Or simple use like this:

...
                        beforeshow: function updateTipBody(tip) {
                            if (item.getWidth() < (tm.getSize(item.text).width) + 5 || item.getWidth() < (tm.getSize(item.html).width) + 5) {
                                tip.update(item.html || item.text);
                            } else {
                                return false;
                            }
                        }
...
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...