WPCubed Product Support

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?

#1 ✎ ♥ 0
15.3k Views 1 links 5 users read 4 min
support

Hi,

Usually there is no problem and it should work alright. Using it myself, too.

Maybe you should as a SetFocus

Julian

#2 ♥ 0

Adding SetFocus did not work.

Will try some other things.

#3 ♥ 0

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?

#4 ♥ 0

Is this Problem solved?

My user are very irritated and in the meanwhile i don't know what to do.
Tried nearly everything but i can't find a solution.

Please help!

Thanks in advance

#5 ♥ 0

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

#7 ♥ 0

Hi Julian,

have you any idea about this problem.
Our customer really bother... (and i harass you) ;-)

Thank you

Patrick

#8 ♥ 0
support

Hi,

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

#9 ♥ 0

Hi,

mail is sended to "support@wptools.de"

Thanks
Patrick

#10 ♥ 0
support

Hi,

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

procedure TWPToolsControlParser.SelectWord(Length: LongInt);
var
  NewPos: LongInt;
begin
  NewPos := FEdit.CPPosition - Length;
  FEdit.CPPosition := NewPos;
  if Length=0 then
       FEdit.HideSelection
  else FEdit.SetSelPosLen(FEdit.CPPosition, Length);
  FEdit.CPPosition := NewPos;
  {$IFDEF WPTOOLS5}
  FEdit.ShowCursor;
  {$ENDIF}
end;

Julian

#11 ♥ 0

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.

#13 ♥ 0
support

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
[](http://www.wpcubed.com/ftp/Ad3DemoWPT5.zip)

Julian

#14 ♥ 0

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;

#15 ♥ 0

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

#17 ♥ 0
This category is archived. No new posts are possible.