Luciano França Posted June 28, 2023 Share Posted June 28, 2023 In this link http://forums.unigui.com/index.php?/topic/5410-cursor-position-in-tunimemo/#comment-98286 I was able to know the column that is the cursor but after a lot of searching and testing I didn't find anything that tells me how to know the line where the cursor is I tried the code below but it doesn't work. JSAddListener('blur', 'function(){ajaxRequest(this, "_blur", ["cpos="+this.codeEditor.cursorPosition().line])}'); Quote Link to comment Share on other sites More sharing options...
Luciano França Posted July 1, 2023 Author Share Posted July 1, 2023 can anyone help with this problem ? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 3, 2023 Share Posted July 3, 2023 On 7/2/2023 at 2:52 AM, Luciano França said: can anyone help with this problem ? Hello, Could you please explain in more detail? What component are you using at all? Quote Link to comment Share on other sites More sharing options...
Luciano França Posted July 3, 2023 Author Share Posted July 3, 2023 6 hours ago, Sherzod said: Hello, Could you please explain in more detail? What component are you using at all? I need in "UniMemo" and "UniSyntaxEdit" Grateful. Quote Link to comment Share on other sites More sharing options...
Luciano França Posted July 5, 2023 Author Share Posted July 5, 2023 On 7/3/2023 at 3:09 AM, Sherzod said: Hello, Could you please explain in more detail? What component are you using at all? I have several situations where I need to know which line the cursor is on in VCL I use Lin := Memo1.CaretPos.y; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 5, 2023 Share Posted July 5, 2023 3 hours ago, Luciano França said: I have several situations where I need to know which line the cursor is on in VCL I use In any case, keep in mind that the Web is not a VCL. But despite this, there are some solutions on the forum, and I advise you to search the forum first and analyze the solutions! For example, for UniSyntaxEdit, UniSyntaxEditEx. And I'm sure you'll find solutions for the analysis for the rest too. Quote Link to comment Share on other sites More sharing options...
Luciano França Posted July 5, 2023 Author Share Posted July 5, 2023 8 hours ago, Sherzod said: In any case, keep in mind that the Web is not a VCL. But despite this, there are some solutions on the forum, and I advise you to search the forum first and analyze the solutions! For example, for UniSyntaxEdit, UniSyntaxEditEx. And I'm sure you'll find solutions for the analysis for the rest too. I believe that the colleague does not understand what I need These posts you passed I had already analyzed and nothing does what I need I need to know which line the cursor is on as I had already mentioned in VCL I achieve this using "Lin := Memo1.CaretPos.y;" A possible dirty solution I just created procedure TMainForm.UniFormCreate(Sender: TObject); begin with UniMemo1.JSInterface do JSAddListener('blur', 'function(){ajaxRequest(this, "_blur", ["cpos="+this.inputEl.dom.selectionStart])}'); end; procedure TMainForm.UniMemo1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = '_blur' then (Sender as TUniMemo).CustomAttribs.Values['cpos'] := Params.Values['cpos']; end; Function F_LineCursorMemo(uniMemo: TUniMemo): Integer; var i, aSelStart: Longint; Texto: String; begin uniMemo.Setfocus; Texto := StringReplace(uniMemo.Text, #13, '', [rfReplaceAll]); aSelStart := StrtoIntDef(uniMemo.CustomAttribs.Values['cpos'], 0); Result := 1; for i := 1 to aSelStart do Begin if (Texto[i] = #10) Then inc(Result); End; end; 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.