turn character replace off

Is there a way to turn off the OSX preference for character substitution for just my app? I’m particularly interested in the smartquotes options.

Take a look at this thread. I think that it has the declares that you are looking for.

https://forum.xojo.com/18439-how-to-prevent-smart-quotes-from-being-entered-into-a-textarea/0

Thanks. I haven’t tested it but it’s likely it works.
Where does one put this declare? I’ve never had to use declares. I found this blog entry, but it doesn’t guide for this choice.
Using Declares In Your Multi-Platform Desktop Apps

If you’re using declares written by someone else, you kind of have to read it to see how to use it.

Some people here like to use self-contained declares and put them in the control’s Open event.
Others prefer to write declares so that they can be used outside of the control.

[quote=357157:@Arthur Gabhart]Thanks. I haven’t tested it but it’s likely it works.
Where does one put this declare? I’ve never had to use declares. I found this blog entry, but it doesn’t guide for this choice.
Using Declares In Your Multi-Platform Desktop Apps[/quote]

The one in that thread is written to be placed in the control’s Open event.
You can see that from this line:

dim myTextArea as ptr = documentView(self.Handle)

It is referring to Self, which is the parent control of the event, or as the docs say “Refers to the primary (main) class containing the code.”

Thanks Jared. I did put it in the Open Event for a control and the analyzer likes most of it.
It had one problem with the code. value

setAutomaticQuoteSubstitutionEnabled(myTextArea, value)

I find that slightly confusing since it is used in the lines above. For Instance

declare sub setAutomaticTextReplacementEnabled lib "Cocoa" _ selector "setAutomaticTextReplacementEnabled:" (id as ptr, value as Boolean)
I’m thinking since I want it off I can use ‘False’. Is that correct? Or can I do something else?

Yeah, that code looks like it’s kind of a mix of the two approaches since it was modified from the original suggestion.

It was originally written to be placed in a method where you would pass in a TextArea and a boolean Value, but the original poster modified it to be used in the Open event.

You are correct, however. If you replace ‘value’ with ‘false’, then it will function as expected in the Open event.

And just for clarity and better understanding of declares, the Cocoa library call is “declared” (much like defining a method) with the code:

declare sub setAutomaticTextReplacementEnabled lib "Cocoa" _ selector "setAutomaticTextReplacementEnabled:" (id as ptr, value as Boolean)

Then that function (or in this case setting a property) is called with the code:

setAutomaticQuoteSubstitutionEnabled(myTextArea, value)

That’s why the compiler doesn’t complain about the use of ‘value’ in the first block; it is just being used to define the parameter that will later be replaced with an actual boolean value when the function is called.

Sweet. I have my first declare

I finally tested the code and got an error

[quote]Error: -[XOJWindow documentView]:
unrecognized selector sent to instance 0x691343e0[/quote]
on the line

dim myTextArea as ptr = documentView(self.Handle)

I’m not sure what could be wrong. Suggestions?

Ahhh, it looks like in this case Self is referring to the Window, not the TextArea.

If you change ‘self’ to ‘me’ the code should work.

Me vs. Self is one of the topics available from the BKeeney training videos:
http://xojo.bkeeney.com/XojoTraining

I know because I’ve listened to it like nine million times. If you’ve got questions, search the list of videos!

I’ll forgive myself for not catching the self vs me. I’ve never used declares before. Glad to know that still applies
I may have to spend time on bkeeney watching videos.