andyhill Posted June 20, 2021 Share Posted June 20, 2021 I have the following script displaying many images (id=00 ... 20):- <img id="00" width="'+IntToStr(w)+'" height="'+IntToStr(h)+'" oncontextmenu="return false" ... Please advise how I can add individual RightClick Events to each <img tag - Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted June 21, 2021 Share Posted June 21, 2021 2 hours ago, andyhill said: <img id="00" width="'+IntToStr(w)+'" height="'+IntToStr(h)+'" oncontextmenu="return false" ... Please advise how I can add individual RightClick Events to each <img tag Hello, Please explain in more detail. What do you want to achieve? Quote Link to comment Share on other sites More sharing options...
andyhill Posted June 21, 2021 Author Share Posted June 21, 2021 I want to add RightClick Ajax Event to <img tag (not default browser contextmenu) Quote Link to comment Share on other sites More sharing options...
Sherzod Posted June 21, 2021 Share Posted June 21, 2021 2 hours ago, andyhill said: <img tag Where do you draw <img>? Quote Link to comment Share on other sites More sharing options...
andyhill Posted June 21, 2021 Author Share Posted June 21, 2021 25 to 50 <img tags inside a htmlframe, all need unique RightClick events Quote Link to comment Share on other sites More sharing options...
Sherzod Posted June 21, 2021 Share Posted June 21, 2021 I will check. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted June 21, 2021 Share Posted June 21, 2021 7 hours ago, andyhill said: 25 to 50 <img tags inside a htmlframe, all need unique RightClick events 1. public { Public declarations } ImgID: string; end; 2. UniHTMLFrame -> HTML <img id="Image1" src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png" alt="google" width="100" height="100" oncontextmenu="return false"> 3. UniHTMLFrame -> ClientEvents -> ExtEvents -> function afterrender(sender, eOpts) { sender.getEl().dom.addEventListener( 'mousedown', function(e) { if (e.target.tagName == 'IMG' && e.button == 2) { ajaxRequest(sender, '_contextmenu', ['imgId='+e.target.id, 'x=' + e.offsetX, 'y=' + e.offsetY]) } } ) } 4. UniHTMLFrame -> OnAjaxEvent -> procedure TMainForm.HTMLFrameAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = '_contextmenu' then begin ImgID := Params.Values['imgId']; UniPopupMenu1.Popup(Params.Values['x'].ToInteger(), Params.Values['y'].ToInteger()); end; end; ... Quote Link to comment Share on other sites More sharing options...
andyhill Posted June 22, 2021 Author Share Posted June 22, 2021 Thank you Sherzod, I now have separate LeftClick and RightClick events without the Browser's contextmenu event will test ... 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.