6
$\begingroup$

A couple of versions of Mathematica ago there was discussion of how one can set focus on a particular input field:

How to set focus of a dialog window?

http://community.wolfram.com/groups/-/m/t/489107

Are any additional methods of accomplishing this possible in more recent versions of Mathematica?

$\endgroup$
0

1 Answer 1

3
$\begingroup$

So to complement Kuba's answer, digging in the CloudObject source code (because there's that auth dialog) you find that even they still use the BoxID system. Look at:

FileNameJoin@{ PacletFind["CloudObject"][[1]]["Location"], "Kernel", "Dialogs.m" } 

where you'll find:

inptFld[dyn:Dynamic[expr_], boxid_, fldtype_, opts:OptionsPattern[]] := InputField[Dynamic[expr], fldtype, ContinuousAction -> True, System`BoxID -> boxid, ImageSize -> {Full, Automatic}, BaseStyle -> { FontFamily -> $BaseFontFamily,	FontWeight -> "Regular",	FontColor -> $InputTextColor, FontSize -> $InputFieldFontSize }, opts]; 

But apparently there is now this:

FrontEnd`MoveCursorToInputField

to be used like:

CreateDialog[ inptFld[Dynamic[a], "asd", String], NotebookDynamicExpression :> ( Refresh[ FrontEnd`MoveCursorToInputField[EvaluationNotebook[], "asd"], None] ) ] 
$\endgroup$
1
  • 1
    $\begingroup$ Pity this does not work: CreateDialog[DynamicName[InputField[Dynamic[a], String], "asd"], NotebookDynamicExpression :> (Refresh[ FrontEnd`MoveCursorToInputField[EvaluationNotebook[], "asd"], None])] $\endgroup$ Commented Sep 7, 2017 at 10:24

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.