Not Sure How object.spellCheckingType Works with native.newTextField()

Hi there,

I’ve looked through the documentation and run some tests on iOS but I’m still unsure as to how object.spellCheckingType works with a native textfield created using native.newTextField().

http://docs.coronalabs.com/daily/api/type/TextField/spellCheckingType.html

http://docs.coronalabs.com/daily/api/library/native/newTextField.html

Is any input that is incorrectly spelled meant to be highlighted by being underlined?

I see no difference when I type an incorrectly spelled word in the textfield from when I type something correct.

I’m testing on an iPhone, as I know this is iOS specific. I have the latest daily build.

If anyone has any examples of this implemented correctly I’d really appreciate it.

Many thanks,

Ian

Hi Ian,

What is your setting for this? And what is or isn’t happening that you expect should happen (or not happen)?

Brent

Hi Brent,

I guess that’s what I’m asking… what should happen? If I enter a misspelled word, what should happen to let me know that?

Thanks,

Ian

Hi Ian,

From the docs, did you link over to Apple’s docs on what should happen? There should be a little link in there which describes what Apple considers as the expected behavior. We’re simply mimicking this. :slight_smile:

Brent

Hi Brent,

See the below post… this one became irrelevant once I’d figured that out so have removed it to avoid confusion.

Thanks,

Ian

Okay - I think I’ve figured out what the issue is but I’m not sure there’s a solution.

I was simply typing one word in and then not hitting space or anything. The app I’m using this for is a kids’ spelling app, which allows parents to input words for their children to learn, so they will be just typing a word and then submitting it.

The spell check only initiates when you hit space to tell the system you’ve finished with that word. Until then it assumes you’re still typing and so doesn’t check for spelling. It makes suggestions if autocorrect is on, but that’s not what I want.

Is there any way to initiate the spellcheck functionality every time a character is pressed so that the word is underlined until spelled correctly?

Alternatively, is there a way to access whether spellcheck has returned a misspelling? Then I could add a space onto the end when submit was pressed, this would trigger spellcheck presumably… and then I could alert the user. Clunky but better than nothing.

If not then I can’t see a way round it.

Here’s how I’m constructing the textfield - pretty straightforward.

local defaultField = native.newTextField( 150, 150, 180, 30 ); defaultField.y = 50; defaultField.x = 320; defaultField.spellCheckingType = "UITextSpellCheckingTypeDefault"

Hi Ian,

Does changing it to this make any difference?

[lua]

defaultField.spellCheckingType = “UITextSpellCheckingTypeYes”

[/lua]

If not, I can’t think of any great way to “force” iOS to alert you to a misspelled word while you’re actually typing it. That’s just not how iOS works, at least not that I’ve ever seen. I suppose you might be able to append a space at the end of the string after the user has submitted the field, and iOS might pick that up and alert them for a misspelling, but I don’t think it’s possible to interactively check spelling as you type a word in.

Of course, a potentially comprehensive (but more intensive) solution would be to create your own word lookup table based on what the parent has typed in. You only briefly described the app, but if the concept is that the parent inputs new words for the child to learn, then you could store those and interactively check against that custom “dictionary” as the child typed them in.

Brent

Thanks Brent - I thought that would be the case. I tried setting it to YES but that made no difference.

I’ve now written my own now that flags up any misspelling whilst typing based on a pretty definitive word list. I’ve split the word list into 26 by letter and analyse the first letter of the word so I just check that list to avoid any slow down. It works okay. Needs some cleaning up but I’ll post the code online once I’ve got it sorted.

Thanks for all your assistance on this to date - much appreciated.

Cheers,

Ian

Hi Ian,

What is your setting for this? And what is or isn’t happening that you expect should happen (or not happen)?

Brent

Hi Brent,

I guess that’s what I’m asking… what should happen? If I enter a misspelled word, what should happen to let me know that?

Thanks,

Ian

Hi Ian,

From the docs, did you link over to Apple’s docs on what should happen? There should be a little link in there which describes what Apple considers as the expected behavior. We’re simply mimicking this. :slight_smile:

Brent

Hi Brent,

See the below post… this one became irrelevant once I’d figured that out so have removed it to avoid confusion.

Thanks,

Ian

Okay - I think I’ve figured out what the issue is but I’m not sure there’s a solution.

I was simply typing one word in and then not hitting space or anything. The app I’m using this for is a kids’ spelling app, which allows parents to input words for their children to learn, so they will be just typing a word and then submitting it.

The spell check only initiates when you hit space to tell the system you’ve finished with that word. Until then it assumes you’re still typing and so doesn’t check for spelling. It makes suggestions if autocorrect is on, but that’s not what I want.

Is there any way to initiate the spellcheck functionality every time a character is pressed so that the word is underlined until spelled correctly?

Alternatively, is there a way to access whether spellcheck has returned a misspelling? Then I could add a space onto the end when submit was pressed, this would trigger spellcheck presumably… and then I could alert the user. Clunky but better than nothing.

If not then I can’t see a way round it.

Here’s how I’m constructing the textfield - pretty straightforward.

local defaultField = native.newTextField( 150, 150, 180, 30 ); defaultField.y = 50; defaultField.x = 320; defaultField.spellCheckingType = "UITextSpellCheckingTypeDefault"

Hi Ian,

Does changing it to this make any difference?

[lua]

defaultField.spellCheckingType = “UITextSpellCheckingTypeYes”

[/lua]

If not, I can’t think of any great way to “force” iOS to alert you to a misspelled word while you’re actually typing it. That’s just not how iOS works, at least not that I’ve ever seen. I suppose you might be able to append a space at the end of the string after the user has submitted the field, and iOS might pick that up and alert them for a misspelling, but I don’t think it’s possible to interactively check spelling as you type a word in.

Of course, a potentially comprehensive (but more intensive) solution would be to create your own word lookup table based on what the parent has typed in. You only briefly described the app, but if the concept is that the parent inputs new words for the child to learn, then you could store those and interactively check against that custom “dictionary” as the child typed them in.

Brent

Thanks Brent - I thought that would be the case. I tried setting it to YES but that made no difference.

I’ve now written my own now that flags up any misspelling whilst typing based on a pretty definitive word list. I’ve split the word list into 26 by letter and analyse the first letter of the word so I just check that list to avoid any slow down. It works okay. Needs some cleaning up but I’ll post the code online once I’ve got it sorted.

Thanks for all your assistance on this to date - much appreciated.

Cheers,

Ian