MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: New lines in InputField

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117726] Re: New lines in InputField
  • From: "Chris Degnen" <degnen at cwgsy.net>
  • Date: Wed, 30 Mar 2011 04:14:35 -0500 (EST)

This seems to be the solution.  FrontEndExecute clues gleaned from 
perdalum's post of January 2010.


CreateDialog[{TextCell["Enter your text here:"],
   InputField[Dynamic[input], String, FieldSize -> {50, 12}],
   DefaultButton[
    DialogReturn[
     CreateDocument[
      Graphics[{Yellow, Rectangle[{0, 0}, {300, 200}], Black,
        Inset[TextCell[input, 12, LineSpacing -> {0, 16},
          TextJustification -> 1], {0, 200}, {Left, Top}, {300,
          Automatic}]}, PlotRange -> {{0, 300}, {0, 200}},
       ImageSize -> {300, 200}]]]]},
  NotebookEventActions -> {"ReturnKeyDown" :>
     FrontEndExecute[{NotebookWrite[InputNotebook[], "\n", After]}]}];



> I spoke too soon.  Using the front end token HandleShiftReturn
> doesn't replicate the correct effect of a pasted-in carriage return,
> as becomes apparent when text justification is applied.
> Is there another front end token that will do the trick?  Thanks
>
>
> CreateDialog[{TextCell["Enter your text here:"], 
> InputField[Dynamic[input], String, FieldSize -> {50, 12}], DefaultButton[
>    DialogReturn[
>     CreateDocument[
>      Graphics[{Yellow, Rectangle[{0, 0}, {300, 200}], Black, 
> Inset[TextCell[input, 12, LineSpacing -> {0, 16}, TextJustification -> 1], 
> {0, 200}, {Left, Top}, {300, Automatic}]}, PlotRange -> {{0, 300}, {0, 
> 200}}, ImageSize -> {300, 200}]]]]}, NotebookEventActions -> 
> {"ReturnKeyDown" :> FrontEndTokenExecute["HandleShiftReturn"]}];
>
>
>
>> Aha, got it.
>>
>> CreateDialog[{TextCell["Enter your text here:"], 
>> InputField[Dynamic[input], String, FieldSize -> {50, 12}], DefaultButton[
>>    DialogReturn[CreateDocument[TextCell[input, "Print"]]]]}, 
>> NotebookEventActions -> {"ReturnKeyDown" :> 
>> FrontEndTokenExecute["HandleShiftReturn"]}];
>>
>>
>>
>>> Can anyone suggest how to enter new lines in input text,
>>> preferably using the return key?
>>> In the example below I can paste into an input field a piece
>>> of text which includes new lines, such as these two sentences,
>>> but new lines can't be typed straight in to the input field,
>>> as users are wont to do.
>>>
>>>
>>> CreateDialog[{TextCell["Enter your text here:"], 
>>> InputField[Dynamic[input], String, FieldSize -> {50, 12}], 
>>> DefaultButton[
>>>    DialogReturn[CreateDocument[TextCell[input, "Print"]]]]}, 
>>> NotebookEventActions -> {}];
>>>




  • Prev by Date: Re: Off Topic: E-Mail Security in this Group
  • Next by Date: Re: specifying further options to NMinimize method when using NonlinearModelFit
  • Previous by thread: Re: New lines in InputField
  • Next by thread: Re: New lines in InputField