10
$\begingroup$

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.

$\endgroup$
1
$\begingroup$

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

$\endgroup$
  • 3
    $\begingroup$ 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. $\endgroup$ – Rolf Mertig Dec 13 '17 at 7:02
  • 1
    $\begingroup$ 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 $\endgroup$ – Kuba Dec 13 '17 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.