picyka Posted June 8, 2021 Share Posted June 8, 2021 Could I publish the OnCellContextClick event? TUniTreeMenu Quote Link to comment Share on other sites More sharing options...
Sherzod Posted June 9, 2021 Share Posted June 9, 2021 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; Quote Link to comment Share on other sites More sharing options...
picyka Posted June 9, 2021 Author Share Posted June 9, 2021 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; Quote Link to comment Share on other sites More sharing options...
picyka Posted June 9, 2021 Author Share Posted June 9, 2021 I want the same behavior as there is in treeview http://prime.fmsoft.net/demo/desktop/mdemo.dll If you can help I will be grateful. Quote Link to comment Share on other sites More sharing options...
picyka Posted June 10, 2021 Author Share Posted June 10, 2021 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() Quote Link to comment Share on other sites More sharing options...
picyka Posted June 18, 2021 Author Share Posted June 18, 2021 Up. 😢 Quote Link to comment Share on other sites More sharing options...
picyka Posted July 31, 2021 Author Share Posted July 31, 2021 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 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 31, 2021 Share Posted July 31, 2021 Hello, Need to check. Do you have a simple testcase? Quote Link to comment Share on other sites More sharing options...
picyka Posted July 31, 2021 Author Share Posted July 31, 2021 39 minutes ago, Sherzod said: Hello, Need to check. Do you have a simple testcase? Note that to trigger ShowMessage, I need to click Menu 1 first TestCase.rar Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 31, 2021 Share Posted July 31, 2021 23 minutes ago, picyka said: TestCase.rar 7.69 MB · 0 downloads I need to check. 1 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 31, 2021 Share Posted July 31, 2021 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; Quote Link to comment Share on other sites More sharing options...
picyka Posted July 31, 2021 Author Share Posted July 31, 2021 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. 😁 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.