10

Is it possible to enable ShowAutoSpellCheck for String InputFields? Similarly to

Panel @ TextCell[
  "errorrr", ShowAutoSpellCheck -> True, LanguageCategory -> "NaturalLanguage"
]

enter image description here

I failed to find a top level way to do this and I struggle with implementation of manual checks, or rather with making result InputField friendly:

mark = Style[#, FontVariations -> {"Underlight" -> Red}, 
    ShowStringCharacters -> False, StripOnInput -> True] &;

check[s_String] := StringRiffle[
   If[DictionaryWordQ[#], #, ToString[mark[#], StandardForm]
      ] & /@ StringSplit[s],
   " "
   ];

x = check@"test errr test"

InputField[Dynamic[x], String]

enter image description here

Looks nice but does not work anymore. This boils down to 'how to create styled strings which can be edited in an InputField'. But I don't claim it is the only what to achieve the goal here.

Any tips?


This topic How to Check Spelling strings written inside input cells is very similar but I think it can be solved, with a some effort, because Format/Style items work on strings in input cells but not in InputField.

Kuba
  • 136,707
  • 13
  • 279
  • 740

1 Answers1

2

Here's a way to use the built-in autocomplete:

s = "wut";
Panel@
 InputField[
  Dynamic[
   TextCell[s,
    ShowAutoStyles -> True,
    ShowAutoSpellCheck -> True, 
    LanguageCategory -> "NaturalLanguage",
    Editable -> True
    ],
   Replace[
    {
     TextCell[str_, ___] :> Set[s, str],
     _ :> Set[s, ""]
     }
    ]
   ]
  ]

asdasdasd

It's kinda buggy when editing though

b3m2a1
  • 46,870
  • 3
  • 92
  • 239
  • 3
    In my experience the whole InputField function is extremely buggy each time I wanted to do something a bit more complicated and user-friendly. InputField really needs a complete overhaul in order to be really usable. – Rolf Mertig Dec 13 '17 at 07:02
  • 1
    For me it never stores entered string, shows it and when the focus is lost "wut" is back. So kinda too buggy for me :P – Kuba Dec 13 '17 at 07:39