Jump to content

Max length on a panel of tunistatusbar


delagoutte

Recommended Posts

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...