Jump to content

how to disable right click on unidbgrid/unistringgrid only


donlego

Recommended Posts

2 hours ago, donlego said:

with UniMainModule.BrowserOptions:=[boDisableMouseRightClick ]  it disable all right click  on browser

but how to disable right click spesific to dbgrid/stringgrid only

Hello,

You can try something like this:

procedure TMainForm.UniFormCreate(Sender: TObject);
var
  IDs: string;
begin
  IDs := UniDBGrid1.JSId + ',' + UniStringGrid1.JSId;
  UniSession.AddJS('document.oncontextmenu = document.body.oncontextmenu = '+
                   '  function (e) { var s=true; e.path.forEach(function(el){'+
                   '    if(el.id!="" && "'+ IDs +'".includes(el.id)){s=false}'+
                   '  });'+
                   'return s}');
end;

 

Link to comment
Share on other sites

  • 1 month later...
On 7/31/2019 at 2:57 AM, Sherzod said:

Hello,

You can try something like this:


procedure TMainForm.UniFormCreate(Sender: TObject);
var
  IDs: string;
begin
  IDs := UniDBGrid1.JSId + ',' + UniStringGrid1.JSId;
  UniSession.AddJS('document.oncontextmenu = document.body.oncontextmenu = '+
                   '  function (e) { var s=true; e.path.forEach(function(el){'+
                   '    if(el.id!="" && "'+ IDs +'".includes(el.id)){s=false}'+
                   '  });'+
                   'return s}');
end;

 

I used this code to block the right mouse button on the stringgrid and I used this other code below to open a poupupmenu, which abge the 2.

procedure TForm.StringGridFaultMouseDown (Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
   if Button = mbRight then
     UniPopupMenu2.Popup (X, Y, StringGridFaults);
end;

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