Group Abstract Group Abstract

Message Boards Message Boards

2
|
10K Views
|
2 Replies
|
4 Total Likes
View groups...
Share
Share this post:

How Do I Set the Focus To a Given Control in a DialogInput[] Statement?

Posted 11 years ago
POSTED BY: Brad Varey
2 Replies
Posted 7 years ago
POSTED BY: b3m2a1 ​ 
Posted 11 years ago

This method is undocumented but used in Input which sets focus on its field automatically.

http://mathematica.stackexchange.com/a/81352/

Moreover it is introduced by WRI quite recently so maybe it will stay.

DialogInput[{name = "", id = ""}, 
 Grid[{{"Name: ",    InputField[Dynamic[name], String,     FieldHint -> "Enter the name"]},
          {"ID: ",    InputField[Dynamic[id], String,    FieldHint -> "Enter the three-digit ID",   
                                             BoxID -> "fieldWithID"]}, 
          {"", 
    Grid[{{Button["OK", DialogReturn[{name, id}],       ImageSize -> Automatic],       Button["Cancel", DialogReturn[{}], 
        ImageSize -> Automatic]}}]}}], 
 WindowTitle -> "Add New Record",
 Initialization :> (
   MathLink`CallFrontEnd[        FrontEnd`BoxReferenceFind[
     FE`BoxReference[InputNotebook[], {{"fieldWithID"}},       FE`BoxOffset -> {FE`BoxChild[1]}, 
      FE`SearchStart -> "StartFromBeginning"]]]
   )]

enter image description here

If you want to avoid undocumented functions, here is a description of approach based on SelectionMove. Probably more stable but not so flexible.

http://mathematica.stackexchange.com/a/1463/5478

POSTED BY: Kuba Podkalicki
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard