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.

I want a column with textcells and a button to add an extra textcell:

Column[{Button["New line"],
TextCell["a", "Text", FontFamily -> "Times", FontWeight -> Plain, Editable -> True]},
Editable -> False]

How to do this? I want the first click to make it be like:

Column[{Button["New line"],
TextCell["However this has been edited", "Text", FontFamily -> "Times", FontWeight -> Plain, Editable -> True],
TextCell["a", "Text", FontFamily -> "Times", FontWeight -> Plain, Editable -> True]},
Editable -> False]
share|improve this question
    
Could you please respond to Michael's answer. Does it fit your needs? –  Kuba Jan 30 at 21:50

1 Answer 1

Perhaps something like this? Using InputField is more convenient than figuring out how to write a text cell that stores its edited text in a dynamically updated variable. (That's basically the function of InputField anyway.)

newline[Dynamic[texts_], text0_: ""] := (
   AppendTo[texts, text0];
   With[{n = Length[texts]},
    InputField[Dynamic[texts[[n]]], String, Appearance -> "Frameless",
      BaseStyle -> {FontFamily -> "Times", FontWeight -> Plain, 
       Editable -> True}, FieldHint -> "enter text"]
    ]);

DynamicModule[{lines, texts = {}, btn},
 lines = {
   newline[Dynamic[texts], "However this has been edited"],
   newline[Dynamic[texts], "a"]};
 btn = Button["New line", AppendTo[lines, newline[Dynamic[texts]]]];
 Dynamic @ Column[{btn} ~Join~ lines, Editable -> False]
 ]
share|improve this answer

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.