14

Just like Albert I recommend using the second argument of Dynamic. Furthermore I recommend that you embrace the first A in AJAX, which stands for "asynchronous", so the kernel isn't busy while it collects the data (this might be why some change events are lost with your code). You can see how well the second argument of Dynamic works with this example: ...


11

You can get custom colors and rounded corners by adding a custom frame to a frameless InputField. The following code approximates the look of Wolfram Alpha's input field: With[{opts = {FrameMargins -> 0, ImageMargins -> 0}}, Framed[ Framed[InputField[, ImageSize -> {500, 25}, Appearance -> "Frameless"], FrameStyle -> ...


11

Perhaps something like this? text = ""; EventHandler[ InputField[Dynamic@text, String, ContinuousAction -> True], {"ReturnKeyDown" :> Paste["\n"]} ]


11

I also took a crack at this. I think I made it look pretty close to the jquery example you posted. Figuring out how to move the insertion point to the end of the word once a suggestion is selected was a bit of a struggle. As a result, there's a DynamicWrapper in there that may be unstable. Input is the list of possible values from which you'd like to draw ...


11

My humble contribution: (* Use this function to style list elements *) listItemStyle[item_] := Mouseover[#, Style[#, Background -> LightBlue]] &@ MouseAppearance[Framed[item], "LinkHand"]; (* This filters the list of data and returns a clickable list *) SetAttributes[autoComplete, HoldFirst]; autoComplete[s_, data_] := If[ StringLength[s] > 0, ...


10

I think the standard way to do this is to use the second argument of Dynamic, e.g. like so: With[{ getCompletion = Function[ Import[ "https://maps.googleapis.com/maps/api/geocode/json", "JSON", "RequestParameters" -> {"address" -> #} ] //. {{r__Rule} :> (Association[r])} ]}, DynamicModule[{ addr = "555 Mission St, San ...


9

The simplest way is just data = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}}; InputField[Dynamic[data]] Dynamic[data] {{1, 2, 3, 4, 55}, {6, 7, 88, 9, 10}}


8

Here is some code I have for entering a 8 digit id number. So this is "out of the box" as is. If you enter more than 8 digits the extra characters are immediately deleted. You can modify to suit your purpose: InputField[Dynamic[id, (id = Which[ StringMatchQ[#, DigitCharacter ..] && StringLength[#] >= 8,StringTake[#, 8], StringMatchQ[#,...


8

Response to edits: I don't know if I got all your points but this is the final update done by me :) v = {0.5, 0.05, 0.1, 0.15, 0.2}; active = Range@Length@v; update[i_, val_] := (v[[i]] = val; With[{range = DeleteCases[active, i]}, v[[range]] = (1 - val) Normalize[v[[range]], Total]]); updateCheckbox[i_, val_] := If[val, active = Join[active, {...


8

InputField[Dynamic[var], Boxes] Column[{InputField[Dynamic[var], Boxes], Dynamic[var], Dynamic[RawBoxes @ var], Dynamic[ToExpression @ var] }]


7

Note: This appears to really slowly in M9, although it works well in M8. It probably is better to use teedr's until it can be figured out what is causing the slow speeds. The following seems to work pretty well. I wrapped the options in a Pane and Framed so the entire row is clickable. ClearAll[AutoInputField]; SetAttributes[AutoInputField, ...


7

Maybe overkill but it was educational to try: DynamicModule[{}, EventHandler[ Overlay[{ Dynamic@Framed[ Row[{Style[x, Transparent, 15, Bold], Style[rest, GrayLevel@.6, 15, Bold]}], ImageSize -> {280, 30}, Alignment -> Top, FrameMargins -> {{5, 0}, {0, 1}}], InputField[Dynamic@x, String, BaseStyle -&...


7

Perhaps this slightly modified version of your code is closer to what you want. Remember, Ctrl+J, not Enter, to start a new line. DynamicModule[{data = "some\ndata"}, Column[{ Framed[ Pane[InputField[Dynamic@data, String, ContinuousAction -> True, Appearance -> None, FieldSize -> {Automatic, {1, Infinity}}], ...


7

Like Mike said in a comment, the key is to use the second argument of Dynamic. In this case I've built a function updateCurrencies which modifies a global variable currencies which holds an Association object with all the currency values in it. currencies = <| "USDollars" -> 0, "Euros" -> 0, "BritishPounds" -> 0, "SwedishKronor" ->...


6

Perhaps, something like: inpF = DynamicSetting[Map[InputField[#, FieldSize -> 2, Alignment -> Center]&, #, {-1}]] &; Use it as (Ctrl+Shift+Enter to evaluate in place after highlighting the right hand side):


5

Edit: Now works with either Enter or Tab, thanks to ybeltukov. Now simplified with your own idea to use Null as the Dynamic variable: list = {}; Dynamic[list] Grid@{{InputField[Dynamic[Null, AppendTo[list, #] &]], Button["Reset", list = {}]}} Type expressions, then press Enter, and watch them appear in list (as viewed with Dynamic). Note that with ...


5

This dialog box version was put together some time ago for Mathematica 7 :- text = ""; DialogInput[{TextCell["Try to type a text with linebreaks :-)"], InputField[Dynamic[text], String, FieldSize -> {30, 6}], DefaultButton[DialogReturn[text]]}, NotebookEventActions -> {"ReturnKeyDown" :> FrontEndExecute[NotebookWrite[InputNotebook[], "\...


5

I'll show you hoe to do it for a 3 x 3 matrix of values. You should be able to extend to 3 x 12 without much trouble First do some initialization. headers = {"Jan", "Feb", "Mar"}; rowLbls = {" ", "Tmax", "Tmed", "Tmin"}; valTbl = ConstantArray[0, {3, 3}]; Next build the spreadsheet. MapThread[Prepend, { Prepend[ Array[InputField[Dynamic@...


5

Update. Thanks to Eldo, Dynamic is needed outside the InputField. DynamicModule[{a = 1, b = 20, fuc = "1"}, Deploy[Style[Panel[Grid[Transpose[ { {"Input Format", "Value"}, {PopupMenu[Dynamic[fuc], {"1", "2"}], Dynamic@InputField[ If[fuc == "1", a, b], Number, Enabled -> Dynamic[fuc == "1"] ...


5

Manipulate[ToExpression[func, TraditionalForm] /. x -> val, {{val, Pi, "x"}, InputField}, {{func, "", "f(x)"}, InputField[##, String] &}]


5

Better to use Table: n = Input["What positive integer would you like to start your matrix with?"]; Table[i + j*n, {j, 0, n - 1}, {i, n}]


5

Try wrapping the Option value in Dynamic: Panel[Column[{InputField[Dynamic[purchaseprice], Number, FieldHint -> "Purchase Price"], InputField[Dynamic[EK], Number, FieldHint -> "Equity capital"], InputField[Dynamic[mortgagerate], Number, FieldHint -> "Mortgage Rate in %"], InputField[Dynamic[supplymentary], Number, FieldHint -&...


5

If you work with Boxes you don't have to worry about evaluations: createExample[] := DynamicModule[{name=""}, Column[{ InputField[Dynamic[name],Boxes, ContinuousAction->True], Button[ "OK", Dynamic @ CellPrint[Cell[BoxData[RowBox[{name, "=", "99999"}]], "Input"]] ] }] ] A short animation:


5

Here's a different way to inject the value of name into the cell: createExample[] := DynamicModule[{name = Null}, Column[{ InputField[Dynamic[name], Hold[Expression]], Button["OK", name /. Hold[v_] :> CellPrint[ExpressionCell[Defer[v = 99999], "Input"]]] }] ] The reason var1 becomes 99999 in the OP's code is that the displayed ...


5

Here is what you can do: x = ToBoxes@Defer@Plot[x, {x, 0, 1}]; InputField[Dynamic[x], Boxes, BaseStyle -> {"Notebook", "Input", ShowCodeAssist -> True, ShowSyntaxStyles -> True} ] Dynamic@x Dynamic@MakeExpression[StripBoxes[x], StandardForm]


4

It appears that an undocumented InputFieldBoxOptions -> {"ReturnEntersInput" -> False} does this: InputField[ Dynamic[x], String , BaseStyle -> InputFieldBoxOptions -> {"ReturnEntersInput" -> False} ] It does not help with numpad Enter which can accidentally evaluate the cell. But that is the case with other answers too so the full answer ...


4

Since the type Number won't allow formatted numbers to be displayed, set the accuracy (or precision) of the displayed value to control the number of digits: InputField[Dynamic[If[h2 == 0, 0., SetAccuracy[h2, 4]], (h2 = Round[#, 0.001]) &], Number] FullForm[h2] (* 0.468` *) It does have the disadvantage that numbers like 0.12 will be displayed as 0....


4

For version 9 or above, one can use CellPrint (or simply Print, as it is a specific case of CellPrint) which does not move the selection and thus preserves the focus on the InputField. EventHandler[InputField["", String], {"ReturnKeyDown" :> CellPrint[Cell["test", "Output"]]} ] Since the above code only works in v9, here is an equivalent with ...


4

This Answer is based upon Kuba's comment above regarding two InputFields, so credit should go to him for the idea, this is just an implementation. However, the problem interested me because I have a similar issue to solve regarding entering units into answers, and this question and Kuba's comment made me think of a related solution to that. One can use ...


4

There are a number of issues here: There is no need to wrap Dynamic around the inner variables of the final input field expression. Indeed, it is harmful as Dynamic is purely a user interface element and acts as a holding wrapper in any other context (like an arithmetic expression). The use of Function in the output expression will cause the variables x ...


Only top voted, non community-wiki answers of a minimum length are eligible