On macOS, in System preferences → Keyboard → Text, it is possible to create some rules to modify texts when they are typed on keyboard.
For example ^2 → ² or 1/4 → ¼, …
First, I don’t know if this exists also on Windows.
In TextArea or TextField, these rules work and it is OK.
My question is : Is it possible to apply these rules on texts created by code?
If yes, how?
On macOS? on Windows?
On macOS Mojave:
System Preferences → Keyboard → Text
gives you an area where you can set up any replacements you like.
Perhaps, my question was not clear.
If the user has a rule to modify 1/4 to ¼, this rule is applied automatically on TextArea and TextField in ma app.
But if I draw a text which contains 1/4, how can I know that the user want to have ¼ and not 1/4.
I made a sample app with a DesktopTextField and a Button.
In the Pressed event of the button, I set the text of the TextField to 1/4 and the text is 1/4 .
But if I type 1/4 in the TextField, automatically the text is change to ¼.
I want to do the same when I set the text by code.
I find your question fairly well explained, in case you wonder. You want to programmatically get the list of text replacements the user has defined in the System Preferences pane to be able to apply the same rules outside of the text areas (like in a plain string variable).
I have to admit I have no idea, sorry. Even considering the MBS plugins, I don’t remember having ever seen this as being possible. On the other hand, I never specifically searched for that either. Perhaps there’s a way…
AFAIK, this functionality is part of Apple’s App Kit framework and pretty much exclusive to the TextField or Text Area. If you want to change this when drawing, you’ll have to take over and do it yourself.
I also do not currently know of a way to directly access Apple’s test replacement engine.
Thank you for your responses.