GetFontName and CPWord

  • Hi, is there a way to get the font of cpword?

    To give you an idea of why I want this, I have implemented an Auto Complete function using AfterCompleteWordEvent. This allows users to type abbreviations and have them replaced by words or phrases. However, I'm also allowing users to insert a special symbol (using a custom-designed font) and I want to be able to exclude these symbols so that they don't trigger AfterCompleteWordEvent if a space is typed after a symbol is inserted.

    This is what I tried:

    This doesn't work, because after inserting a symbol, I change the font back to the original font (for instance Arial) so that a symbol can be inserted and then the user can continue typing. So by the time the AfterCompleteWordEvent is triggered, I can't check the current font to see if a symbol has been entered.

    Hence my original question - is there some way to get the font of cpword, or the previous word?

    Einmal editiert, zuletzt von germ (31. August 2010 um 02:47)

  • Okay, my fix goes something like this:

    Code
    TWPRichText(Sender).CPMoveBack;
    try
      if CompareText(TWPRichText(Sender).CPAttr.FontName, SYMBOL_FONT_NAME) = 0 then
        exit;
    finally
      TWPRichText(Sender).CPMoveNext;
      TWPRichText(Sender).GetCharAttr;
    end;

    A little bit messy, moving the cursor back and then forward again, but it seems to work well.