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.

Per this question, I have created a custom graphical control object which evaluates to a list of values. I would like to be able to create such an object quickly, rather than typing some command, pressing shift+enter, then copying the resulting object into wherever I want to use it. For example, something like typing \[Theta] which turns into θ... is it possible to create such a custom shorthand notation? (Even better, is it possible that when I start to type in a function which takes such a list as arguments, it pops up this control object for me to type the values in?)

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

Assuming you are referring to this control. You can

  • Evaluate in a separate cell each time and copy paste (you don't like this)
  • Write the command and evaluate in place
  • Copy the control once and paste it several times: remember the variables were localized so each will have its own copy and they won't interfere
  • Create a palette

    CreatePalette@PasteButton["Paste control", myControl["a"~CharacterRange~"g"]];
    
  • Create a toolbar

    AppendTo[CurrentValue[InputNotebook[], DockedCells], 
     Cell@BoxData@
       ToBoxes@PasteButton["Paste control", 
         myControl["a"~CharacterRange~"g"]]]
    
  • Create an input alias, or an input auto replacement. Example of input alias (the other one is the same)

    AppendTo[CurrentValue[InputNotebook[], InputAliases], 
     "control" -> ToBoxes@myControl["a"~CharacterRange~"g"]]
    
share|improve this answer
    
Thanks, this lead me to find InputAutoReplacements which was what I wanted. Do you have any idea why it selects a random field/object in the box instead of highlighting the first text field when the replacement happens? –  jtbandes Nov 24 '12 at 1:05
    
@jtbandes not off the top of my head. Generally \[SelectionPlaceholder]s are used to represent where the selection will go so you could try initializing the control with that character –  Rojo Nov 24 '12 at 19:12
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.