I need a Palette with editable InputField.

When I try the code CreatePalette[Pane[InputField["Enter a string"]]] it makes the pallete but all input goes into an open notebook, not into the InputField.

I just need a Palette with editable InputField. How it can be done?

  • 1
    $\begingroup$ Palettes seem to be made for buttons, I'm pretty sure you need CreateDialog. $\endgroup$
    – Kurt
    Mar 30, 2015 at 17:34
  • $\begingroup$ Care to provide some code to show how CreateDialog can be used to address the OP's issue? It would make your answer more helpful and probably solicit some rep. $\endgroup$ Mar 30, 2015 at 17:54

3 Answers 3


The following code should fix the problem:

CreatePalette[Pane[InputField["Enter a string"]], WindowFloating -> False,
WindowClickSelect -> True];

But as we figured out it is not!

I read all available information about WindowClickSelect and WindowFloating options in Mathematica documentation.

I didn't find any notices that we can't use the options simultaneously. I also didn't find any cautions that we can't use the options with Mathematica palettes.

Thus, such unexpected behavior is probably a bug in Mathematica. I advice to contact Wolfram support team regarding this bug.

  • $\begingroup$ It works! :) Thank you Helen! $\endgroup$
    – Norb
    Mar 15, 2012 at 7:41
  • 1
    $\begingroup$ I found strange behavior. When use this option I can't execute a cell anymore (Mathematica beeps). F1 to open help system and Ctrl+S to save the nb doesn't work correctly. $\endgroup$
    – Norb
    Mar 15, 2012 at 7:49
  • 3
    $\begingroup$ Try to set the option WindowFloating to False. $\endgroup$
    – helen
    Mar 15, 2012 at 8:02
  • 2
    $\begingroup$ WindowFloating really helps. But when I use these options, another problems have arisen. As far as I understand, now the focus of the palette on the InputFiles. So, when I try to use another Mathematica palette to paste something to the notebook, it is pasted into the InputFiled of the my palette. Moreover, I can't use PasteButton in my palette (Mathematica beeps again). So, even with these options I can't create the pallete that works correctly. $\endgroup$
    – Norb
    Mar 15, 2012 at 8:26
  • $\begingroup$ On Mathematica v11.0, this code runs from a notebook (and works), but doesn't seem to allow the palette to actually be installed. The Install Palette drop down menu doesn't recognize the new palette (assuming a WindowTitle is inserted into your code) to install it. $\endgroup$
    – Todd Allen
    Jan 6, 2017 at 1:09

It seems you can't have everything in one, but maybe everything in 1.5 will be ok:

  DynamicModule[{string = ""},
     InputField[Dynamic@string, String],
     string = InputString["", string],
     Appearance -> None, Method -> "Queued"


As of 11. something this is nice and easy, if you're on Mac. It seems this does not work for Windows.

We'll leverage FrontEnd`MoveCursorToInputField and SetSelectedNotebook to temporarily overcome the WindowClickSelect issue.

paletteInputField[specs__] :=

 With[{uuid = CreateUUID["input-field-"]},
   InputField[specs, BoxID -> uuid],
    "MouseClicked" :>
     If[EvaluationNotebook[] =!= SelectedNotebook[],
        {TaggingRules, "OldSelection"}
        ] = SelectedNotebook[];
      FrontEnd`MoveCursorToInputField[EvaluationNotebook[], uuid]],
    "MouseExited" :>
      SelectionMove[EvaluationCell[], All, Cell];
         {TaggingRules, "OldSelection"}
    PassEventsDown -> True

This then works (almost) exactly as expected:

 paletteInputField["asdasd", String],
 WindowMargins -> Automatic,
 System`ClosingSaveDialog -> False,
 WindowSize -> 300

Note the "MouseExited" call there. This just passes focus back to the previously selected notebook so nothing wonky happens and moves the selection point for aesthetic reasons.

And we don't lose WindowFloating either.

  • $\begingroup$ On Win10 the content of IF is selected but when I start typing it writes to previously used notebook. $\endgroup$
    – Kuba
    Nov 24, 2017 at 8:43
  • $\begingroup$ @Kuba ah the joys of the FE. I guess this is maybe a Mac-only solution then. What happens if you stick a SetOptions[EvaluationNotebook[], Selectable->True] in the "MouseClicked" call? $\endgroup$
    – b3m2a1
    Nov 24, 2017 at 8:45
  • $\begingroup$ Nope, same story, guess OS dependent. But I wonder how much use if of that if it will break/interfere with typical palette's buttons which assume InputNotebook is not the ParentNotebook. Hmm, maybe this boils down to 'how to create floating dialog' rather than 'editable palette'. $\endgroup$
    – Kuba
    Nov 24, 2017 at 8:49
  • $\begingroup$ @Kuba I can get around that one using "MouseExited". The not properly getting focus issue is more concerning to me. $\endgroup$
    – b3m2a1
    Nov 24, 2017 at 8:55
  • $\begingroup$ Another comment, don't feel targeted, I just want to point issues people will likely face because I deal with people who try to break my code on daily basis :) So, first of all "MouseExited" is commonly used but still undocumented :(, second, when you move cursor during typing it will switch selection, it is clearly unlike any input field/ text area experience so people will complain / find it cumbersome. Again, not your fault, I know the pain. $\endgroup$
    – Kuba
    Nov 24, 2017 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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