How do I suppress the chr(34) quote character to « or » replacements in a TextArea?

macOS X Tahoe,
Xojo 2025r2.1

When I type "Emile" in a TextArea, I get: « Emile ».

That project generate an html file and sometimes, I had to manually modify html code.

To do that, I copy my html code to TextEdit, make the change and paste the new html code.

Not the best.

Ideas ?

PS: the Allow Style Text property is set to False.
image

That was Gemini answer :frowning:

Because you are French, and the OS has automatic spellchecking/substitutions turned on.

Here is the system setting on a Mac - smart quotes

Windows is somewhere else

Hi Jeff.

Thank you for your answer.

My macOS Tahoe is set to US-en, but it do the replacement and I am in a catch22 situation: I do not want to change the preferences nth times a day and was hopping for a code solution (set to no replacement on Application activate / set it to do replacement on deactivate rather manually.

That is how I learned to change preferences, and I love that.

If no other solution, I will continue to copy/paste the whole html code.

Regards.

You may be able to do this with a declare

I think this is the attribute he needs, but I don’t offhand have the code to implement it:

This is the declare for disabling quote replacement, dash replacement, and automatic text replacement for spellcheck.

declare function NSClassFromString lib "Cocoa" (aClassName as CFStringRef) as Ptr

declare function documentView lib "Cocoa" selector "documentView" _
(obj_id as Integer) as Ptr

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

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

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

dim myTextArea as ptr = documentView(me.Handle)

setAutomaticQuoteSubstitutionEnabled(myTextArea, false)
setAutomaticDashSubstitutionEnabled(myTextArea, false)
setAutomaticTextReplacementEnabled(myTextArea, false)

It might need to be modified for API 2 since I pulled this from old code before I started using MBS for stuff like this.

It’s also easy in MBS:

dim n as NSTextViewMBS = me.NSTextViewMBS
n.AutomaticQuoteSubstitutionEnabled = false
n.AutomaticDashSubstitutionEnabled = false
n.AutomaticLinkDetectionEnabled = false
n.AutomaticDashSubstitutionEnabled = false
n.AutomaticTextReplacementEnabled = false
2 Likes

Thank you all.

I prefer:

// Activated Event:
If TextArea1.Substiture Then
TextArea1.Substiture = False
End If
// Desactivated Event:
If Not TextArea1.Substiture Then
TextArea1.Substiture = True
End If

That cannot be expensive to build in… :wink:

It’s not available cross platform so it probably won’t be. You could make your own extension method for TextArea that uses the declares though.

Funny, after I clicked in Reply, this idea comes to my mind.

Whats the point of this?

The textarea is in your app.

Every time it gets the focus, you set it to false. There is never a point at which you want TextArea1.Substiture = True

just add TextArea1.Substiture = False in the gotfocus / activated ?

Oh… I only want to set the property as it was on entry.

Maybe I forgot something…

I may have been wrong (I am searching / making a quest against an OutOfBounds Exception in a TextArea since too many hours, failing miserably to find who is the faultive String Array… so my brain is more error prone than usually.

I also make a typo in Substitute (not the only one i’ve done today).