mayusod Posted June 2, 2015 Share Posted June 2, 2015 is posible know the cursor position in a TuniMemo ??? Thanks Quote Link to comment Share on other sites More sharing options...
Sherzod Posted June 2, 2015 Share Posted June 2, 2015 Hi, Try: procedure TMainForm.UniButton1Click(Sender: TObject); begin UniSession.AddJS('var el = document.getElementById("'+UniMemo1.JSName+'_id-inputEl"); val = el.value; alert(val.slice(0, el.selectionStart).length)'); end; Best regards! Quote Link to comment Share on other sites More sharing options...
mayusod Posted June 2, 2015 Author Share Posted June 2, 2015 Thanks, Delphi Devoloper Quote Link to comment Share on other sites More sharing options...
Tokay Posted October 15, 2021 Share Posted October 15, 2021 Up. I need to get caret pos, the line where currently text cursor located. Does it possible to request this info to the back side? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 15, 2021 Share Posted October 15, 2021 Hello, Yes, the forum has solutions if I'm not mistaken. Quote Link to comment Share on other sites More sharing options...
Tokay Posted October 15, 2021 Share Posted October 15, 2021 Sorry, I could not found it. I already saw 100+ topics, but have no success. I've found my own old topic: With link here: But I don't understand how it could help me. I need this behaviour: push a button on the form, do request to a TUniMemo and get the line where the text cursor curently located in the TUniMemo. Thank you! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 15, 2021 Share Posted October 15, 2021 25 minutes ago, Tokay said: I need this behaviour: push a button on the form, do request to a TUniMemo and get the line where the text cursor curently located in the TUniMemo. Thank you! For example, one possible solution. 1. procedure TMainForm.UniFormCreate(Sender: TObject); begin with UniMemo1.JSInterface do JSAddListener('blur', 'function(){ajaxRequest(this, "_blur", ["cpos="+this.inputEl.dom.selectionStart])}'); end; 2. procedure TMainForm.UniMemo1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = '_blur' then (Sender as TUniMemo).CustomAttribs.Values['cpos'] := Params.Values['cpos']; end; 3. Usage: procedure TMainForm.UniButton1Click(Sender: TObject); begin ShowMessage(UniMemo1.CustomAttribs.Values['cpos']) end; Quote Link to comment Share on other sites More sharing options...
Tokay Posted October 15, 2021 Share Posted October 15, 2021 Thank you! Your solution works as needed! 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.