andyhill Posted May 15, 2021 Share Posted May 15, 2021 Looking for advice on how to detect a uni canvas mouse RightClick ? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 15, 2021 Share Posted May 15, 2021 1 hour ago, andyhill said: Looking for advice on how to detect a uni canvas mouse RightClick ? Hello, One possible solution for now: function afterrender(sender, eOpts) { sender.getEl().dom.addEventListener('contextmenu', function(){ ajaxRequest(sender, ...) }) } Quote Link to comment Share on other sites More sharing options...
andyhill Posted May 15, 2021 Author Share Posted May 15, 2021 Thank You Sherzod. Issue, this brings up the Browser context popup "Save Image" etc, I want this for my use only - not the browser. Also, There is no x/y or any other previous mouse down event preceding the RightClick, how do I know where the RightClick was clicked ? Please advise ? Minimal testing on several mouse events shows eOpts is blank "console.log(eOpts);" On another matter dealing with the canvas object, I need a completed event after:- image loaded lines drawn flood fill completed clear beginupdate endupdate etc. The OnReadyEvent only fires once after initialization, can it not be made to fire after any drawing begin-end event (have I missed something) ? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 16, 2021 Share Posted May 16, 2021 8 hours ago, andyhill said: Issue, this brings up the Browser context popup "Save Image" etc, I want this for my use only - not the browser. function afterrender(sender, eOpts) { sender.getEl().dom.addEventListener('contextmenu', function(e){ //ajaxRequest(sender, ...) e.preventDefault() }) } Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 16, 2021 Share Posted May 16, 2021 9 hours ago, andyhill said: Issue, this brings up the Browser context popup "Save Image" etc, I want this for my use only - not the browser. Also, There is no x/y or any other previous mouse down event preceding the RightClick, how do I know where the RightClick was clicked ? Please advise ? 1. UniCanvas1 -> ClientEvents -> ExtEvents -> function afterrender(sender, eOpts) { sender.getEl().dom.addEventListener('contextmenu', function(e){ ajaxRequest(sender, '_contextmenu', ['x=' + e.layerX, 'y=' + e.layerY]); e.preventDefault(); }) } 2. procedure TMainForm.UniCanvas1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = '_contextmenu' then begin UniPopupMenu1.Popup(Params.Values['x'].ToInteger + 10, Params.Values['y'].ToInteger + 10) end; end; Quote Link to comment Share on other sites More sharing options...
andyhill Posted May 16, 2021 Author Share Posted May 16, 2021 Thank You Sherzod - your the Master. Can you please ADD to the canvas object an event that "fires after any drawing endupdate" please. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 17, 2021 Share Posted May 17, 2021 4 hours ago, andyhill said: Can you please ADD to the canvas object an event that "fires after any drawing endupdate" please. Are you using "UniCanvas1.PaintMode := pmFreeHand;" ? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 17, 2021 Share Posted May 17, 2021 9 hours ago, andyhill said: Can you please ADD to the canvas object an event that "fires after any drawing endupdate" please. 4 hours ago, Sherzod said: Are you using "UniCanvas1.PaintMode := pmFreeHand;" ? Some approaches can be analyzed from here: https://stackoverflow.com/questions/4648465/does-canvas-element-have-change-event/ Quote Link to comment Share on other sites More sharing options...
andyhill Posted May 17, 2021 Author Share Posted May 17, 2021 Thanks Sherzod 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.