Jump to content

TUniTreeMenu


picyka

Recommended Posts

5 hours ago, picyka said:

Could I publish the OnCellContextClick event?

TUniTreeMenu

Hello,

If I understand you correctly, maybe something like this?

function mousedown(sender, x, y, eOpts)
{
    if (eOpts == 2) {
        ajaxRequest(sender, '_contextmenu', ['x='+x, 'y='+y]);
    }
}
procedure TMainForm.UniTreeMenu1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName = '_contextmenu' then
  begin
    UniPopupMenu1.Popup(Params.Values['x'].ToInteger(), Params.Values['y'].ToInteger())
  end;

end;

 

Link to comment
Share on other sites

6 horas atrás, Sherzod disse:

Olá

Se eu te entendo corretamente, talvez algo assim?


function mousedown(sender, x, y, eOpts)
{
    if (eOpts == 2) {
        ajaxRequest(sender, '_contextmenu', ['x='+x, 'y='+y]);
    }
}

procedure TMainForm.UniTreeMenu1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName = '_contextmenu' then
  begin
    UniPopupMenu1.Popup(Params.Values['x'].ToInteger(), Params.Values['y'].ToInteger())
  end;

end;

 

It works, but would be able to click to force select the item? I wanted to do something like that

 

procedure TMainForm.CopiarMenu1Click(Sender: TObject);
begin
  if Self.UniTreeMenu.Selected.Count = 0 then
    var l := Self.UniTreeMenu.Selected.AttachedMenuItem.Hint;
end;

 

Link to comment
Share on other sites

On 6/9/2021 at 1:27 AM, Sherzod said:

Hello,

If I understand you correctly, maybe something like this?


function mousedown(sender, x, y, eOpts)
{
    if (eOpts == 2) {
        ajaxRequest(sender, '_contextmenu', ['x='+x, 'y='+y]);
    }
}

procedure TMainForm.UniTreeMenu1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName = '_contextmenu' then
  begin
    UniPopupMenu1.Popup(Params.Values['x'].ToInteger(), Params.Values['y'].ToInteger())
  end;

end;

 

Would it be possible to send the index of the client's object to the server?

 

Self.UniTreeMenu.Selected.SelectedIndex := Params.Values['idx'].ToInteger()

Link to comment
Share on other sites

  • 1 month later...
On 6/9/2021 at 1:27 AM, Sherzod said:

Hello,

If I understand you correctly, maybe something like this?


function mousedown(sender, x, y, eOpts)
{
    if (eOpts == 2) {
        ajaxRequest(sender, '_contextmenu', ['x='+x, 'y='+y]);
    }
}

procedure TMainForm.UniTreeMenu1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName = '_contextmenu' then
  begin
    UniPopupMenu1.Popup(Params.Values['x'].ToInteger(), Params.Values['y'].ToInteger())
  end;

end;

 

Sherzod, did you understand me?

 

when I run _contextmenu, it opens the menu just fine, but it doesn't select node

Link to comment
Share on other sites

5 hours ago, picyka said:

TestCase.rar 7.69 MB · 1 download

Hello,

Can you try this approach?

1.

function mousedown(sender, x, y, eOpts)
{
    if (eOpts == 2) {
        ajaxRequest(sender, '_contextmenu', ['x='+x, 'y='+y]);
    }
}

2. 

function afterrender(sender, eOpts) 
{
    var tMenu = sender;
    var tree = tMenu.treeMenu;

    tree.getEl().dom.addEventListener('mousedown', function(e) {  
        if (e.button == 2) {
            var li = Ext.get(e.target).up('li');
            if (li) {
                var id = li.getAttribute('data-recordid');
                tree.setSelection(tree.itemMap[id]._node.id);
                ajaxRequest(tMenu, '_contextmenu', ['x=' + (e.x - tMenu.getX()), 'y=' + (e.y - tMenu.getY())])
            }
        }
    });
}

3.

procedure TMainForm.UniTreeMenu1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName = '_contextmenu' then
  begin
    UniPopupMenu1.Popup(Params.Values['x'].ToInteger(), Params.Values['y'].ToInteger())
  end;
end;

 

Link to comment
Share on other sites

2 hours ago, Sherzod said:

Olá

Pode tentar essa abordagem?

1.


function mousedown(sender, x, y, eOpts)
{
    if (eOpts == 2) {
        ajaxRequest(sender, '_contextmenu', ['x='+x, 'y='+y]);
    }
}

2. 


function afterrender(sender, eOpts) 
{
    var tMenu = sender;
    var tree = tMenu.treeMenu;

    tree.getEl().dom.addEventListener('mousedown', function(e) {  
        if (e.button == 2) {
            var li = Ext.get(e.target).up('li');
            if (li) {
                var id = li.getAttribute('data-recordid');
                tree.setSelection(tree.itemMap[id]._node.id);
                ajaxRequest(tMenu, '_contextmenu', ['x=' + (e.x - tMenu.getX()), 'y=' + (e.y - tMenu.getY())])
            }
        }
    });
}

3.


procedure TMainForm.UniTreeMenu1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName = '_contextmenu' then
  begin
    UniPopupMenu1.Popup(Params.Values['x'].ToInteger(), Params.Values['y'].ToInteger())
  end;
end;

 

Very good, very top, best support in the world. 😁

  • Like 1
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...