problem with setting CPPosition/Addict

  • I am trying to return the cursor to the original position after executing an action(mailmerge, spellcheck,etc)

    Before I execute the action I call:
    CursorPos:=WPRichText1.CPPosition;

    When done, I call:
    WPRichText1.CPPosition:=CursorPos;

    The cursor appears to go to the right position. However, when you begin to type, the cursor jumps all the way to 0,0 and starts typing there.

    What is the recommended way to handle this in WPT5?

    Einmal editiert, zuletzt von Bobby (7. Juni 2006 um 18:06)

  • Ok, I've pretty much narrowed this down to a problem with WPTools or WPTAddict and the current versions. Maybe an update broke something.

    Normally, in Addict, setting the EndCursorPosition to epOriginal returns the cursor to the position that it was in before invoking the spell check. This works fine in the standalone Addict demo.

    It does not work with the WPTAddict demo included with WPTools. It used to work, so I can only guess that some update, either to WPTools, or to WPTAddict.pas, broke it somewhere along the way.

    Now, even manually trying to set the cursor position after spell checking does not work properly. The cursor 'appears' to reposition properly, but if you press a key, it moves to the cursor to the top of the document.

    Anyone have any ideas?

  • Julian,

    you can test it starting your example with AddictSpell. Try Spelling text and set the cursor (with mouse) somewhere in text. Everything you write is not at the position you set the cursor. Set the cursor again at the position you will write, everything is fine.
    Setting the cursor with the cursor key everything fine, too.

    With our Editor, based on WP, nearly hundreds of people are writing documents in health care. They need spelling the text and day for day i get calls from our user. And sometimes they are not very friendly...

    Please help

    Thanks
    Patrick

    • Offizieller Beitrag

    Hi,

    Zitat

    Try Spelling text and set the cursor (with mouse) somewhere in text. Everything you write is not at the position you set the cursor.

    I tried that in my demo with the included version of the unit WPTAddict.pas. I don't get this effect. You may send me the WPTAddict unit which you now use. Maybe it locks the cursor movement somewhere.

    Julian

    • Offizieller Beitrag

    Hi,

    the problem can be solved in unit WPTAddict.pas by updating this method:

    Julian

  • Julian

    I've tried the fix but I still have the problem. Have done a Build having loaded the dpk and then installing.

    I rightclick on a misspelt word and select a correction.

    The cursor is now at the start of the word.

    I click at the end of the line and the cursor moves there.

    I start typing and the characters appear at the beginning of the corrected word.

    • Offizieller Beitrag

    Hi,

    this was something else,

    please correct at the end of

    procedure TWPTAddictInstance.WPOnMouseDownRight(

    this code

    if (PopupResult <> spCancel) then
    begin
    {$IFDEF WPTOOLS5}
    TWPCustomRtfEdit(FLiveControl).HideSelection;
    TWPCustomRtfEdit(FLiveControl).CPPosition := Pos + Length(Text);
    {$ELSE}
    TWPCustomRtfEdit(FLiveControl).SetSelPosLen(Pos + Length(Text), 0);
    {$ENDIF}
    end;


    I updated the archive
    https://www.wpcubed.com/ftp/Ad3DemoWPT5.zip

    Julian

  • Hi Julian,

    you must do this also or you can't select something after rightclick on a misspelt word.


    if (PopupResult <> spCancel) then
    begin
    {$IFDEF WPTOOLS5}
    //new
    TWPCustomRtfEdit(FLiveControl).TextCursor.DisableTextSelection := False;
    //New
    TWPCustomRtfEdit(FLiveControl).HideSelection;
    TWPCustomRtfEdit(FLiveControl).CPPosition := Pos + Length(Text);
    {$ELSE}
    TWPCustomRtfEdit(FLiveControl).SetSelPosLen(Pos + Length(Text), 0);
    {$ENDIF}
    end;

  • I am having a hard time implementing this fix. I have modified wptaddict.pas as mentioned in this thread and rebuilt the package to no avail. I am editing the file in the demo folder is this correct? Also has this fix been added to the latest build?

    Thanks
    Daniel