Re: trying to use InputField as a continually attentive
- To: mathgroup at smc.vnet.net
- Subject: [mg108837] Re: trying to use InputField as a continually attentive
- From: Jaebum Jung <jaebum at wolfram.com>
- Date: Sat, 3 Apr 2010 06:07:30 -0500 (EST)
You could try this with EventHandler msgs={};DynamicModule[{ins=""},EventHandler[InputField[Dynamic[ins],String,ContinuousAction->True],{"ReturnKeyDown":>(msgs=AppendTo[msgs,ins];ins="";)}]] Dynamic[Column@msgs] - Jaebum On 4/2/10 5:20 AM, mkr wrote: > I am trying to set up some interactive code where I issue short > instruction strings to drive some additional dynamic code. > > My hope was to use an InputField into which I could continuously type > these short instructions, with a given character sequence ("do" in the > code below) acting as the trigger (I was guessing that using the > [Enter] key might not work). > > There are a couple of immediate problem behaviors that I observe: > first, when InputField input contains spaces, the cursor keeps getting > moved to inside of the string, second, after ending a string with > "do", the cursor ends up to the right of the InputField, requiring a > [<-] keypress to get the cursor back into the InputField. > > I am using 7.0.1 on XP. Code follows: > > > > msgs={}; > procstring[ins_String]:=If[StringLength[ins]>1&&StringTake[ins, > {-2,-1}]=="do",AppendTo[msgs,StringTake[ins,{1,-3}]];"",ins] > > FullForm@procstring["process thisdo"]; > FullForm@procstring["and thisdo"]; > FullForm@procstring["but not this"]; > msgs > > ins=""; > InputField[Dynamic[ins,(ins=procstring[#])&],String,ContinuousAction- > >> True] >> > Dynamic[Column@msgs] > > > > Any help fixing this approach, or with some other technique for > achieving the same general sort of input mechanism by another > approach, would be greatly appreciated. > > Thanks, > > Miles > >