How to disable smart quotes (autocorrect) in TextFields

I have a use case where I want to set the contents of a text field or let the user edit the contents of a text field.

Sometimes if the user is typing into the textfield things like quotes get replaced with smart quotes.

image

If a user wants to set the content of a textfield on an artboard or I want to set the contents of a textfield programmatically and I want to make sure XD does not change it (at all) what must I do? Note: Smart quotes will break my plugin functionality.

Is it possible to tell XD that this field should not try and autocorrect any typed in values?

Pseudo code:

var textfield = selection.items(0);
textfield.disableAutocorrect(true);
textfield.content = `Markup: <p color="blue">here's my markup</p>`;

Or on the artboard:

artboard.disableAutocorrect(true);
var textfield = selection.items(0);
textfield.content = `Markup: <p color="blue">here's my markup</p>`;

Use case:
Quincy is creating a XD guide plugin that explains all the uses of each object on the artboard. When the plugin is enabled the user selects an object like a rectangle. When this happens the plugin draws a line and a descriptive textfield to the artboard describing the rectangle. When the user selects an ellipse the rectangle description and line is removed and a new line and textfield is added describing the ellipse. Some of the descriptive text contains code samples and other unique non-ascii characters.

As he’s finishing up the plugin he notices some of the text in the text field is being reformatted by XD. He adds a line of code to disable autoformatting on the text field and this fixes it.

1 Like

This may actually be being done by the OS. At least under macOS I think that’s the case.

2 Likes

That was it.

I disabled that setting and reopened the XD document and it stopped using smart quotes.

Before:

After:

If that’s the case, I don’t think that setting a textfield value programmatically will use smart quotes because it’s not using the operating system text entry but I haven’t confirmed this.

However, this disables smart quotes system wide. I found online that some text fields allow you to select the quote and replace it with regular quotes. But in XD textfields it does not display the same options.

Ackshually, smart quotes might not be a problem for my use case.

if I’m setting the text field contents and the OS does not change the nornal quotes to smart quotes then if the user opens the text field and copies the content to the clipboard the quotes are not converted.

My use case is I might add code snippets to the artboards in a text field but code editors break when you use smart quotes.