Auto capitalisation

  • I've just been asked for

    On a new text document the first letter should default to uppercase.

    After a period or as some peeps call it a full stop, howabout an
    automatic space + next letter uppercase.

    Is there a property somewhere to do this or do I have to do it myself? If so guidance would be appreciated.

  • I implemented auto capitalization a long time ago (about 1.5 years) using an override an the following procedure.

    Code
    TWPCustomRtfEdit.DoAfterCompleteWordEvent

    There is also a property AfterCompleteWordEvent that can be used.

    The only problem is that DoAfterCompleteWordEvent isn't triggered when starting a new paragraph, so i had to trigger it myself.

    I remember BeforeInitializePar not being sufficient, becuase it didn't trigger immediately and also because i liked it to work like Ms Word where you can override the auto-capitalization by retyping the same word in lowercase, but this does require some more work to implement.

    [/code]

  • Zitat von RoyLambert

    Thanks I tried searching on autocaptialise, never thought of putting a hyphen in <g>

    I only knew it was there because I asked the same thing a while back :)

    • Offizieller Beitrag

    Hi,

    I recommend to use the event BeforeInitializePar for this - but only for the current paragraph!

    This following code is a new approach. It seems to work pretty nice and allows it to undo the auto change - something I find important. It handles abbreviations! Any suggestions are welcome.

    Regards,

    Julian Ziersch

  • The code is somewhat integrated with the rest of our application. And i'm not allowed to share our source code, but i can give some code segments.

    I made this code when we still used WpTools 3 and converted it when we upgraded to WpTools 5, so it's not by any means optimized for WpTools 5. I can't even guarantee that everything still works, since i haven't maintained this code through many releases of WpTools.


    [/code]

  • Zitat von wpsupport

    Hi,

    This following code is a new approach. It seems to work pretty nice and allows it to undo the auto change - something I find important. It handles abbreviations! Any suggestions are welcome.Regards,

    Julian Ziersch

    for me, this is doing p.M. for abbreviations. (p.M. hour) For three letters it does 'a.B.c'. The word following the abbreviation is good though.

  • Is this correct?

    // Check for abbreviation (simplified - only check a..z
    and ((par.IsSpace(i-1) or (par.CharItem[i]<or>='a') and (par.CharItem[i-1]<='z') and par.IsSpace(i+1) )) )
    then

    • Offizieller Beitrag

    Hi,

    I forgot the "disable HTML", this damaged the post ....

    Julian