Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

If I have a bunch of input fields, I can tab between them quite conveniently, but if I want to navigate between the input fields and another element (in my case, a button), I have to click on the button manually. Is there any option or other code construct that would allow the user to tab out of an input field and takes the focus to the button? Ideally I could just press enter and the button would activate. A simple example:

Column[{
  TableForm[{ 
    Row[{
      InputField[Dynamic@var, Number, ImageSize -> 150], 
      InputField[Dynamic@unit, String, ImageSize -> 150]
    }]// Deploy
  }],
  Button["print", Print[#1] & [Quantity[var, unit]]]
}]
share|improve this question
add comment

1 Answer 1

This is not an answer. It is a suggestion about how you might simplify your code. I suggest that the simpler expression

Column[{
  Row[{
    InputField[Dynamic @ var, Number, ImageSize -> 150], 
    InputField[Dynamic @ unit, String, ImageSize -> 150]
  }],
  Button["Print", Print[Quantity[var, unit]]]
}]

will work just a well as the one you have posted. More generally, I suggest never combining TableForm with Row, Column, or Grid.

share|improve this answer
    
Ok, thanks! Can I ask why you'd avoid TableForm? –  user15921 Jun 13 at 12:43
    
@user15921. I don't say avoid TableForm. It's fine when used alone, TableForm is very old -- goes all the back to Version 1. Row, Column, and Grid are much newer (Version 6) and much more capable. They can do everything TableForm can do and much more. This means that TableForm simply isn't necessary when you use the newer formatting functions. Further, there are situations where the old and new formatting functions don't play well together. In your code TableForm wasn't doing any harm, it simply wasn't having any effect. –  m_goldberg Jun 13 at 13:12
    
That makes sense. Thanks for explaining! –  user15921 Jun 13 at 13:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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