WPCubed Product Support

Addict/WPTools auto-correct problem.

I'm posting this here because I know the Addict folks read this, and I'm not sure which is the source of the issue.

Using WPTools 5.20.5 and Addict 3.4.5 Pro. My application uses the exact implementation as in the WPTools Addict demo. This problem exists in the demo as well.

Normally, after entering text that should fire an autocorrect and pressing space, the word is filled in. At this time, only the last four letters of the word show. However, if you press return, the rest will show. It seems to be some sort of painting issue.

To reproduce in the demo, add a new auto-correct
wpt WPTools

if you type 'wpt' then space, all that shows is 'ools'. If you press return now, it will show 'WPTools' as it should.

Any idea what might cause this?

#1 ♥ 0
17.2k Views 7 users read 4 min

Hi bobby,

I was getting the exact same problem, but since I had to fix another problem, this one has been fixed as well. The problem that I fixed is about and "extra blank space after AutoCorrect". If you note, the AutoCorrect feature adds an extra blank space, so you will have two blank spaces after the AutoCorrected word.

I sent the fixes to Julian but he didn't add it to version 5.20.5, so I'm waiting for him to publish in the next release (5.20.6).

Hope this helps

Alessandro Fragnani

#2 ♥ 0

Bobby,

Thanks for drawing this to our attention 🙂

It seems that the problem doesn't exist with the demo we currently have online at:

Which was built with WPTools 5.18.5

However when I rebuild with WPTools 5.20.5 I see the same problem.

I can also confirm that the Autocorrect works correctly in our Addict 3.4.5 Demo.

So I think something may have changed from the WPTools side of things - but I am uncertain whether this just requires a parser change. I've also just noted that the Addict/WPTools parser included in 5.20.5 has had a few minor adjustments done to it compared to the one we currently have online. So I'll check that out as well - Julian is often doing improvements to the parser and we are very grateful to him for that 🙂

#4 ♥ 0

Alessandro, would you mind sending me the fix for this?

#6 ♥ 0
support

Hi,

In WPCtrMemo, KeyPress replace the code at the end of this procedure with

end else
        begin
         // #32 ->
          if (not FCPWordModified) and  //<--- !!!!!!!!!
             not ((GetAsyncKeyState(VK_CONTROL) < 0) or
            (GetAsyncKeyState(VK_SHIFT) < 0) or (GetAsyncKeyState(VK_LSHIFT) < 0)) then
          begin
            if FJustCreatedAutomaticHyperlink then CloseAutoLink;
            FMemo.InputString(#32, true, FMemo._CodePage);
            ChangeApplied;
            ShowCursor;
            FMemo.RTFData.NewUndolevel;
          end;
        end;

Julian

#7 ♥ 0

Julian, I've made this change and recompiled, but now it's showing the last five characters instead of the last four. The full text is still not shown until you press return.

#8 ♥ 0

Hi Bobby,

please change in WPTAddict.pas

procedure TWPTAddictInstance.WPOnAfterCompleteWord(Sender: TObject; var lastchar: Char);
var
  Correction: string;
begin
  if Assigned(FAddictSpell) and FLiveCorrect then
  begin
    if (FAddictSpell.WordHasCorrection(FLiveControl.CPWord, Correction)) then
    begin
      FLiveControl.CPWord := Correction;
      //new
      FLiveControl.DelayedReformat;
      FLiveControl.ReformatAll();
      //new    
    end;
  end;

  if (Assigned(FOldOnAfterCompleteWord)) then
  begin
    FOldOnAfterCompleteWord(Sender, lastchar);
  end;
end;

With the changes Julian made in WPCTRMemo.pas and then two new lines, everything seems to be ok!!! 😃

Regards
Patrick

#9 ♥ 0

That last bit did the trick.

Thanks Pat!

And also to Alessandro, Glenn and Julian.

#10 ♥ 0

I've implemented both changes, but when I autocorrect a certain string, the whole paragraph disappears. It looks like the text-color is changed to white (on a white background)?

#11 ♥ 0

also add this from Alessandro and it should work. There are three changes that have to be made it looks like.

unit WPCTRMemo.pas
procedure TWPCustomRtfEdit.KeyPress

      if WPWordDelimiterArray[key] then
      begin
        DoAfterCompleteWordEvent(key);
        if FCPWordModified and (key = #32) then
        begin
          AddHistoryChar(#0);
          // AFM - instead of this...
          //Memo.InputString(#32); // Otherwise skipped!
          // AFM - use this
          FMemo.InputString(#32, true, FMemo._CodePage);
          ChangeApplied;
          ShowCursor;
          FMemo.RTFData.NewUndolevel;
        end;
      end;
#12 ♥ 0

Julian, did this fix make it into the new build? .6

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