andyhill Posted June 26, 2020 Posted June 26, 2020 Please show me how I can identify the InLine image that was selected when it was Double Clicked - Thanks. procedure TfMain.HtmlMemoDblClick(Sender: TObject); begin // Get Selected Object From Sender ? end; Quote
Sherzod Posted June 26, 2020 Posted June 26, 2020 32 minutes ago, andyhill said: how I can identify the InLine image that was selected when it was Double Clicked Maybe something like this?: function initialize(sender, eOpts) { sender.getDoc().addEventListener('dblclick', function(){ if (arguments[0].target && arguments[0].target.tagName.toLowerCase()=='img') { alert(arguments[0].target.getAttribute('id')); //ajaxRequest } }); } Quote
andyhill Posted June 26, 2020 Author Posted June 26, 2020 HtmlMemo.ClientEvents.ExtEvents.Clear; s:= 'initialize=function initialize(sender, eOpts) '+ '{ '+ ' sender.getDoc().addEventListener(''dblclick'', function() '+ ' { '+ ' if (arguments[0].target && arguments[0].target.tagName.toLowerCase()==''img'') '+ ' { '+ ' alert(arguments[0].target.getAttribute(''id'')); '+ ' } '+ ' }); '+ '} '; HtmlMemo.ClientEvents.ExtEvents.Add(s); // Alert event fires: 'id' Always shows null 'dblclick' event fires: 'id' Always shows '' //////////////////////////////////////////////////////////////////////////////////////////////////// HtmlMemo.ClientEvents.ExtEvents.Clear; s:= 'initialize=function initialize(sender, eOpts) '+ '{ '+ ' sender.getDoc().addEventListener(''dblclick'', function() '+ ' { '+ ' if (arguments[0].target && arguments[0].target.tagName.toLowerCase()==''img'') '+ ' { '+ ' ajaxRequest(sender, ''_img_'', ["id="+arguments[0].target.getAttribute(''id'')]); '+ ' } '+ ' }); '+ '} '; HtmlMemo.ClientEvents.ExtEvents.Add(s); // 'dblclick' event fires: 'id' Always shows '' '_img_' event fires, 'id' Always shows '' Please advise ? Quote
Sherzod Posted June 26, 2020 Posted June 26, 2020 4 minutes ago, andyhill said: Alert event fires: 'id' Always shows null <img id="img1">..... Quote
Sherzod Posted June 26, 2020 Posted June 26, 2020 6 minutes ago, Sherzod said: <img id="img1">..... ? Quote
andyhill Posted June 26, 2020 Author Posted June 26, 2020 Yes, works in _img_ event but not in dblclick event but I now understand why - thank you. Also can you resolve inline issue mentioned earlier. In addition if you drag an image inside HtmlMemo it disappears ??? Quote
Sherzod Posted June 26, 2020 Posted June 26, 2020 44 minutes ago, andyhill said: Also can you resolve inline issue mentioned earlier. Can you please explain in more detail? Quote
andyhill Posted June 26, 2020 Author Posted June 26, 2020 Run this code:- InlineData:= '<img id="img1" src="data:image/jpeg; charset=utf-8; base64, /9j/4AAQSkZJRgABAQEBLAEsAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcU FhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgo KCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wgARCAAyAGQDASIA AhEBAxEB/8QAGwABAAIDAQEAAAAAAAAAAAAAAAQFAQIDBgf/xAAZAQEBAQEBAQAAAAAAAAAAAAAA AQMCBAX/2gAMAwEAAhADEAAAAfqgGu1dE3aHXpeZqZNStauGemeZsNObYZ98eEulx1ix5sayBMh3 feNF03gaOvaBL7vo7Kg62+hGJGk44tXift4tvGW1h0+h5okOz6S1Glvm2MuM9UOYAAAAAAB//8QA IhAAAwEAAQQCAwEAAAAAAAAAAQIDBAAFERITEDEgISIw/9oACAEBAAEFAvknsPMcBB4WA4D34zdu CgJ/LRVQnvmESwlyWny5Jy1b18dF9fpGuosem0d48q/rVbh4roagZfZ00A+tIvQ+62ipptpxw1mO Z7Uz4gIxkkU4frPAnk8LLfWyVU0XxyapCVfCN7sTLO3iK6fSnStFqnpuutrfF6etdP8ARCmqHCpy Jld6UileoCffLoxoucdPj7ZYjGePI0bfKT8Ub9DtUMq0HGSvcK/k6VI7U4Pr/f8A/8QAIREAAgIB BAIDAAAAAAAAAAAAAREAAhASEyExIjBBQoH/2gAIAQMBAT8Bw8NQWZWKCpr5Tdszo/JZfMT4mj6m bawEDzN1BCWrq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zhwA9cS05ff1dCKIjlJApFoXR8YumkUIPawyTBoB TvgQdcvWMDDn2ahoOb/jAkFWsUSAD22vRk5GSQewAF9rxgjz1z3A3ODVw5g6cXh0q8mz750zU04v f1n8P//Z" alt="" width="100" height="50" style="display: block; margin-left: 4px; margin-top: 2px;">'; UniSession.AddJS(HtmlMemo.JSName + '.insertAtCursor('+ Chr(39)+InlineData+Chr(39) +')'); Quote
andyhill Posted June 27, 2020 Author Posted June 27, 2020 Sherzod, Have you run this code and got errors like me, if so how do we fix ? Quote
Sherzod Posted June 27, 2020 Posted June 27, 2020 6 hours ago, andyhill said: src="data:image/jpeg; charset=utf-8; base64," /9j/4AAQSkZJR.... it seems you have extra quotes after base64," Quote
andyhill Posted June 27, 2020 Author Posted June 27, 2020 The actual data is wrapped by double quotes, if you take the complete tag string, turn it into a html file and execute it by the browser it all works. Quote
andyhill Posted June 27, 2020 Author Posted June 27, 2020 Please advise, script code in file attached - please run in browser. Why does the same script not run in HtmlMemo ? InlineData.html Quote
andyhill Posted June 29, 2020 Author Posted June 29, 2020 How many times must I ask, if it is a bug then acknowledge it please along with fix ETA, if it is my code then please explain why it works in browsers but not in your HtmlMemo ? Quote
Sherzod Posted June 29, 2020 Posted June 29, 2020 Please make a simple testcase for reproduce and to check. Quote
Sherzod Posted June 29, 2020 Posted June 29, 2020 4 hours ago, andyhill said: How many times must I ask, if it is a bug then acknowledge it please along with fix ETA, if it is my code then please explain why it works in browsers but not in your HtmlMemo ? This is not a bug. You need use like this... 1. Add to uses list: Uses ... ,ExtPascalUtils; 2. StrToJS procedure TMainForm.UniButton1Click(Sender: TObject); var MyList: TStringList; HtmlStr: String; begin UniHTMLMemo1.Clear; UniSession.AddJS(UniHTMLMemo1.JSName + '.insertAtCursor('+ Chr(39)+'Before Image<br>'+Chr(39) +')'); MyList:= TStringList.Create; try MyList.LoadFromFile(UniServerModule.StartPath+'\files\InlineData.html'); HtmlStr:= StrToJS(MyList.Text); except end; MyList.Free; UniSession.AddJS(UniHTMLMemo1.JSName + '.insertAtCursor('+ HtmlStr +')'); end; Quote
Sherzod Posted June 29, 2020 Posted June 29, 2020 Or use like this: procedure TMainForm.UniButton1Click(Sender: TObject); var MyList: TStringList; HtmlStr: String; begin UniHTMLMemo1.Clear; UniSession.AddJS(UniHTMLMemo1.JSName + '.insertAtCursor('+ Chr(39)+'Before Image<br>'+Chr(39) +')'); MyList:= TStringList.Create; try MyList.LoadFromFile(UniServerModule.StartPath+'\files\InlineData.html'); //HtmlStr:= StrToJS(MyList.Text); HtmlStr:= MyList.Text; except end; MyList.Free; //UniSession.AddJS(UniHTMLMemo1.JSName + '.insertAtCursor('+ HtmlStr +')'); UniHTMLMemo1.JSInterface.JSCallDefer('insertAtCursor', [HtmlStr], 300); end; Quote
andyhill Posted June 29, 2020 Author Posted June 29, 2020 Thank You Sherzod. Feed back:- First Option (StrToJS) only works in an empty paragraph Second Option ([]) inserts between characters and empty paragraphs Would you please explain why we have to deal with inline differently ? Quote
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.