BUG: TWebMemo is missing CaretPos

I'm wanting to create a "join lines" hotkey that works in a TWebMemo: position the cursor on a line, hit <ctrl>-J or <alt>-J or something like that and the current line has the next line appended to it with a space in between. I can't get anything to happen, but worse, none of the ways to get the line# where the cursor is at that work with a TMemo work with a TWebMemo, even thouth TWebMemo seems to be derived from TCustomMemo. Suggestions are welcome.

In the mean time, this is an issue:

Trying to access memo.CaretPos gives a compiler error:

[Error] myForm1(1953): identifier not found "CaretPos"

I even tried this:

type
  TmyMemo = class (TCustomMemo)
  public
    function GetCaretPos: TPoint; override;
  end;

  function TmyMemo.GetCaretPos: TPoint;
  begin
    Result := inherited GetCaretPos;
  end;

The compiler says this:

[Error] myForm1(1944): There is no method in an ancestor class to be overridden "function GetCaretPos of Object"

However, vcl.std.ctrls shows this:

  TCustomMemo = class(TCustomEdit)
  private
    FLines: TStrings;
    FScrollBars: System.UITypes.TScrollStyle;
    FWordWrap: Boolean;
    FWantReturns: Boolean;
    FWantTabs: Boolean;
    class constructor Create;
    class destructor Destroy;
    procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE;
    procedure WMNCDestroy(var Message: TWMNCDestroy); message WM_NCDESTROY;
  protected
    procedure CreateParams(var Params: TCreateParams); override;
    procedure CreateWindowHandle(const Params: TCreateParams); override;
    function GetCaretPos: TPoint; virtual;    <------
    procedure DoGetGestureOptions(var Gestures: TInteractiveGestures;
      var Options: TInteractiveGestureOptions); override;
. . .

I explained this situation with VCL design-time vs WEB Core run-time components already several times.
Like recently here TWebCheckListBox error with TCheckBoxState - #15 by Schwartz_David
It's a similar case.
In the next version, we'll make this particular public property also available in WEB Core run-time.

Is there any way to solve this problem given what IS there?

I can't even seem to get a key handler to recognize when I type <ctrl>-J in the memo! Is that another thing that's also not implemented yet?

I just want to be able to have a hot-key option to join two lines in the memo -- ANY of the memo components is fine, and ANY hot-key combination is fine. Just position the cursor on a line and hit a hot-key combo to join the next line to it. That's all I need.

What are my options TODAY? That's all I want to know. I'm sure there's a workaround.

BTW, just looking at properties or methods that are documented as being available, it's hard to tell what's going on when the compiler says they're missing. There can be a number of reasons for that. If they were flagged as "temporarily unavailable due to underlying compatibility issues" that would be helpful at least explaining the deficiency. Adding a note on a workaround would also be helpful.

Absent that, all users can do is report what we encounter that appear to be compiler issues or stuff missing in the class definitions, because the docs say these methods are present.

  1. For now you can use SelectionStart to calculate the caret as X,Y from there. We can confirm that in the next update, there will be a CaretPos.
  2. In OnKeyDown, Ctrl-J is received. I do notice this is a built-in shortcut too in Chrome.
1 Like