Extra character on AfterCompleteWordEvent

  • I am trying to use AfterCompleteWordEvent for templates, somewhat like coderush.

    I have the following code and it works except I still get the "+" in my WPRichText.

    procedure TfmVetJournal.edJournalAfterCompleteWordEvent(Sender: TObject;
    var lastchar: Char);
    begin
    if lastchar = '+' then
    if CompleteComment(edJournal.CPWord) then
    begin
    lastchar := #0;
    edJournal.Repaint;
    end;
    end;

    I also tried using OnKeyDown to have Ctrl-Space as my trigger but I still get the space character in my WPRichText.

    case Key of
    ...
    VK_SPACE:
    begin
    if ssCtrl in Shift then
    begin
    Key := 0;
    CompleteComment(edJournal.CPWord);
    edJournal.Repaint;
    end;
    end;
    end;

    Why can't I get rid of the character from the buffer?

    Thanks,
    Tony

  • I was unable to change the source. I got the following error

    [Error] WPRich.pas(485): Declaration of 'DoAfterCompleteWordEvent' differs from previous declaration

    I don't appear to have the source for the previous declaration...