Jump to content

Popupmenu and Tunitreeview


eric

Recommended Posts

Hello,

 

I'd like to use a tpopupmenu in a treeview. the feature works well,  when I right click  I get my popupmenu on the 

correct item.

 

procedure TUniWizard_Update.UniTreeView1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin

     if Button=mbRight then     

     UniPopupMenu1.Popup(X, Y,unitreeview1); 

end;

 

The problem is that  the TreeView1Change event  is fired only on the   left Click . so I don't know How to get the selected node

in a right click.

 

Thanks for your help

 

eric

Link to comment
Share on other sites

Yes, I'm sorry, there is a problem with the cancellation of the event "selectionchange" when used with the "mousedown" event..

I will try analyze..

 

By the way, there are right way than I gave the link above
for enable right click for the node selection:

 

UniTreeview1 -> ClientEvents -> UniEvents ... [Ext.tree.Panel] beforeInit fn

function beforeInit(sender, config)
{
  sender.selModel = {
    ignoreRightMouseSelection: false
  }
}

Best regards.

Link to comment
Share on other sites

Hi,

 

For now, you can like this:

 

1.

UniTreeview1 -> ClientEvents -> UniEvents ... [Ext.tree.Panel] beforeInit fn

function beforeInit(sender, config)
{
  sender.selModel = {
    ignoreRightMouseSelection: false
  }
}

2. UniTreeview1 -> ClientEvents -> ExtEvents ...

function itemmousedown(sender, record, item, index, e, eOpts)
{   
  if (e.button == 2){
    function _showPopup() {
      ajaxRequest(sender.ownerCt, '_showPopup', ['x='+e.xy[0], 'y='+e.xy[1]])
    }
    setTimeout(_showPopup, 200)
  }
}

3.

procedure TMainForm.UniTreeView1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TStrings);
begin
  if EventName = '_showPopup' then begin
    UniPopupMenu1.Popup(StrToInt(Params.Values['x']), StrToInt(Params.Values['y']));
  end;
end;

4.

procedure TMainForm.UniTreeView1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  //if Button=mbRight then
  //  UniPopupMenu1.Popup(X, Y,unitreeview1);
end;

Try..

 

Best regards.

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
  • 2 years later...

Hey DD,

I used to use thgis piece of code with previous version. But not the event is not fired in 6.5.

I got the following error .

any idea ?

 

eric 

 

Uncaught TypeError: Cannot read property '0' of undefined
    at _showPopup (eval at AjaxSuccess (ext-unicommon-min.js:9), <anonymous>:1:6708)

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