Jump to content

UNITreeMenu:How to display the total text where the mouse stay on the menu item?


55143681

Recommended Posts

9 hours ago, 风吹小机机 said:

Is there one that displays hint only when it is too long

Can you try this approach?

function store.nodeappend(sender, node, index, eOpts)
{
    var _this=this;
    this.treePanel.getItem(node).el.on('mouseover', function() {
        textMetrics = new Ext.util.TextMetrics();
        tWidth      = textMetrics.getWidth(node.data.text);
        if (tWidth > _this.treePanel.getWidth()) {
            _this.treePanel.getItem(node).el.dom.setAttribute('data-qtip', node.data.text);
        }
    });
    
    this.treePanel.getItem(node).el.on('mouseout', function() {
        _this.treePanel.getItem(node).el.dom.setAttribute('data-qtip', '');
    });
}

 

Link to comment
Share on other sites

13 hours ago, Sherzod said:

Can you try this approach?


function store.nodeappend(sender, node, index, eOpts)
{
    var _this=this;
    this.treePanel.getItem(node).el.on('mouseover', function() {
        textMetrics = new Ext.util.TextMetrics();
        tWidth      = textMetrics.getWidth(node.data.text);
        if (tWidth > _this.treePanel.getWidth()) {
            _this.treePanel.getItem(node).el.dom.setAttribute('data-qtip', node.data.text);
        }
    });
    
    this.treePanel.getItem(node).el.on('mouseout', function() {
        _this.treePanel.getItem(node).el.dom.setAttribute('data-qtip', '');
    });
}

 

Hi
I have tested this and I didn't Work.

regards 

Link to comment
Share on other sites

21 minutes ago, M.Ammar said:

GridFiltering-2.rar 1.54 MB · 0 downloads

Thanks for the testcase.

Yes you are right. 

Okay. Let's take into account the width of the icon.

tWidth += 30;

function store.nodeappend(sender, node, index, eOpts)
{
    var _this=this;
    this.treePanel.getItem(node).el.on('mouseover', function() {
        textMetrics = new Ext.util.TextMetrics();
        tWidth      = textMetrics.getWidth(node.data.text);
        tWidth     += 30;
        if (tWidth > _this.treePanel.getWidth()) {
            _this.treePanel.getItem(node).el.dom.setAttribute('data-qtip', node.data.text);
        }
    });
    
    this.treePanel.getItem(node).el.on('mouseout', function() {
        _this.treePanel.getItem(node).el.dom.setAttribute('data-qtip', '');
    });
}

 

  • Like 1
Link to comment
Share on other sites

19 minutes ago, Sherzod said:

Thanks for the testcase.

Yes you are right. 

Okay. Let's take into account the width of the icon.

tWidth += 30;


function store.nodeappend(sender, node, index, eOpts)
{
    var _this=this;
    this.treePanel.getItem(node).el.on('mouseover', function() {
        textMetrics = new Ext.util.TextMetrics();
        tWidth      = textMetrics.getWidth(node.data.text);
        tWidth     += 30;
        if (tWidth > _this.treePanel.getWidth()) {
            _this.treePanel.getItem(node).el.dom.setAttribute('data-qtip', node.data.text);
        }
    });
    
    this.treePanel.getItem(node).el.on('mouseout', function() {
        _this.treePanel.getItem(node).el.dom.setAttribute('data-qtip', '');
    });
}

 

Thanks Sherzod 

Working Perfect for English,

Note: For Arabic I had to add 130 not 30.

Regards

  • Like 1
Link to comment
Share on other sites

17 hours ago, Sherzod said:

Can you try this approach?


function store.nodeappend(sender, node, index, eOpts)
{
    var _this=this;
    this.treePanel.getItem(node).el.on('mouseover', function() {
        textMetrics = new Ext.util.TextMetrics();
        tWidth      = textMetrics.getWidth(node.data.text);
        if (tWidth > _this.treePanel.getWidth()) {
            _this.treePanel.getItem(node).el.dom.setAttribute('data-qtip', node.data.text);
        }
    });
    
    this.treePanel.getItem(node).el.on('mouseout', function() {
        _this.treePanel.getItem(node).el.dom.setAttribute('data-qtip', '');
    });
}

 

Useful,

But there is still a small problem. When I blur the search menu, it fails

Link to comment
Share on other sites

4 hours ago, 风吹小机机 said:

Thank you, please

Can you try this approach?

pROCEDURE TMainForm.cREATEnODE;
var
  I: Integer;
BEGIN
  //UniTreeMenu1.Items.Clear;
  for I := UniTreeMenu1.Items.Count-1 downto 0 do
    UniTreeMenu1.Items.Delete(UniTreeMenu1.Items[I]);

  UniTreeMenu1.ClientEvents.ExtEvents.Values['store.nodeappend'] :=
    'function store.nodeappend(sender, node, index, eOpts)'+
    '{                                                    '+
    '    var _this=this;                                  '+
    '    this.treePanel.getItem(node).el.on("mouseover", function() {'+
    '        textMetrics = new Ext.util.TextMetrics();               '+
    '        tWidth      = textMetrics.getWidth(node.data.text);     '+
    '        tWidth     += 30;                                       '+ //130
    '        if (tWidth > _this.treePanel.getWidth()) {              '+
    '            _this.treePanel.getItem(node).el.dom.setAttribute("data-qtip", node.data.text);'+
    '        }                                                       '+
    '    });                                                         '+
    '                                                                '+
    '    this.treePanel.getItem(node).el.on("mouseout", function() { '+
    '        _this.treePanel.getItem(node).el.dom.setAttribute("data-qtip", "");'+
    '    }); '+
    '}       ';

  UniTreeMenu1.Items.Add(nil,'AAAAAAAAAAAAAAAAAAAAAAAAAA');
  UniTreeMenu1.Items.Add(nil,'BBBBBBBBBBBBBBBBBBBBBBBBBB');
  UniTreeMenu1.Items.Add(nil,'CCCCCCCCCCCCCCCCCCCCCCCCCC');
END;

 

Link to comment
Share on other sites

2 hours ago, Sherzod said:

Can you try this approach?


pROCEDURE TMainForm.cREATEnODE;
var
  I: Integer;
BEGIN
  //UniTreeMenu1.Items.Clear;
  for I := UniTreeMenu1.Items.Count-1 downto 0 do
    UniTreeMenu1.Items.Delete(UniTreeMenu1.Items[I]);

  UniTreeMenu1.ClientEvents.ExtEvents.Values['store.nodeappend'] :=
    'function store.nodeappend(sender, node, index, eOpts)'+
    '{                                                    '+
    '    var _this=this;                                  '+
    '    this.treePanel.getItem(node).el.on("mouseover", function() {'+
    '        textMetrics = new Ext.util.TextMetrics();               '+
    '        tWidth      = textMetrics.getWidth(node.data.text);     '+
    '        tWidth     += 30;                                       '+ //130
    '        if (tWidth > _this.treePanel.getWidth()) {              '+
    '            _this.treePanel.getItem(node).el.dom.setAttribute("data-qtip", node.data.text);'+
    '        }                                                       '+
    '    });                                                         '+
    '                                                                '+
    '    this.treePanel.getItem(node).el.on("mouseout", function() { '+
    '        _this.treePanel.getItem(node).el.dom.setAttribute("data-qtip", "");'+
    '    }); '+
    '}       ';

  UniTreeMenu1.Items.Add(nil,'AAAAAAAAAAAAAAAAAAAAAAAAAA');
  UniTreeMenu1.Items.Add(nil,'BBBBBBBBBBBBBBBBBBBBBBBBBB');
  UniTreeMenu1.Items.Add(nil,'CCCCCCCCCCCCCCCCCCCCCCCCCC');
END;

Thank you very very much. It works

Unitreemen1.items.clear cannot be used;

It must be deleted from the lowest level node upward

 

Link to comment
Share on other sites

  • 1 year later...
Em 27/7/2021 às 4:46 am, Sherzod disse:

Obrigado pela prova.

Sim, você está certo.

Ok. Vamos levar em conta a largura do ícone.

tWidth += 30;

function store.nodeappend(sender, node, index, eOpts)
{
    var _this=this;
    this.treePanel.getItem(node).el.on('mouseover', function() {
        textMetrics = new Ext.util.TextMetrics();
        tWidth      = textMetrics.getWidth(node.data.text);
        tWidth     += 30;
        if (tWidth > _this.treePanel.getWidth()) {
            _this.treePanel.getItem(node).el.dom.setAttribute('data-qtip', node.data.text);
        }
    });
    
    this.treePanel.getItem(node).el.on('mouseout', function() {
        _this.treePanel.getItem(node).el.dom.setAttribute('data-qtip', '');
    });
}

 

I have some rules there that prevent it from working, can you help me?

Demo.zip

Link to comment
Share on other sites

19 minutes ago, picyka said:
if (tWidth > _this.treePanel.getWidth()) {
           _this.treePanel.getItem(node).el.dom.setAttribute('data-qtip', node.data.text);
       }

The problem is with this rule.

function store.nodeappend(sender, node, index, eOpts)
{
  var _this=this;
  
  this.treePanel.getItem(node).el.on('mouseover', function() {
       textMetrics = new Ext.util.TextMetrics();
       tWidth      = textMetrics.getWidth(node.data.text);
       tWidth     += (50 * node.data.depth);
       if (tWidth > _this.treePanel.getWidth()) {
           _this.treePanel.getItem(node).el.dom.setAttribute('data-qtip', node.data.text);
       }
  });
    
  this.treePanel.getItem(node).el.on('mouseout', function() {
       _this.treePanel.getItem(node).el.dom.setAttribute('data-qtip', '');
  });
}

 

Sorted out

Link to comment
Share on other sites

2 minutes ago, picyka said:
function store.nodeappend(sender, node, index, eOpts)
{
  var _this=this;
  
  this.treePanel.getItem(node).el.on('mouseover', function() {
       textMetrics = new Ext.util.TextMetrics();
       tWidth      = textMetrics.getWidth(node.data.text);
       tWidth     += (50 * node.data.depth);
       if (tWidth > _this.treePanel.getWidth()) {
           _this.treePanel.getItem(node).el.dom.setAttribute('data-qtip', node.data.text);
       }
  });
    
  this.treePanel.getItem(node).el.on('mouseout', function() {
       _this.treePanel.getItem(node).el.dom.setAttribute('data-qtip', '');
  });
}

 

Sorted out

Testing better here, it doesn't work as expected, it would be nice if you know that the menu has...

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...