Page 1 of 1
					
				Last entered word in filed
				Posted: Fri Jun 10, 2016 9:45 am
				by shalu
				Hi All,
I have text field, when I type anything and press space bar the field become empty. If I press up arrow  then it should display the last command (like linux terminal) , If I press down arrow also display the nex command . How I do this  

 
			
					
				Re: Last entered word in filed
				Posted: Sat Jun 11, 2016 1:51 pm
				by dunbarx
				Hi.
Do you mean that you want the field to "become" empty when you press spacebar? That is easy.
But what do you mean by "the last" or "the next"  command?
Craig Newman
			 
			
					
				Re: Last entered word in filed
				Posted: Sat Jun 11, 2016 6:11 pm
				by jmburnod
				Hi Craig,
But what do you mean by "the last" or "the next" command?
I think expected behavior is same of messages box.
Best
Jean-Marc
 
			
					
				Re: Last entered word in filed
				Posted: Sun Jun 12, 2016 1:28 pm
				by dunbarx
				Shalu.
So is Jean-Marc correct? You want this field to work like the message box? Interesting challenge if so, but please confirm.
Craig
			 
			
					
				Re: Last entered word in filed
				Posted: Mon Jun 13, 2016 6:37 am
				by shalu
				@dunbarx sorry for the late reply,  I want a field like 
When  I type any text and press space bar the field should be empty
When I press up-arrow the field should display last typed text
			 
			
					
				Re: Last entered word in filed
				Posted: Mon Jun 13, 2016 3:07 pm
				by dunbarx
				OK. I did this in two handlers for readability. You need to pay me by rewriting in a single handler. Now which message should you use?
In a field script:
Code: Select all
on keyDown tkey
   put tKey after me
   set the lastText of me to me
   if tkey is space then put "" into me
end keyDown
on rawKeyDown tKey
   if tKey = 65362 then set the text of me to the lastText of me
   select after text of me
   pass rawKeyDown
end rawKeyDown
Get going.
Craig
 
			
					
				Re: Last entered word in filed
				Posted: Tue Jun 14, 2016 7:09 am
				by shalu
				@dunbarx This is awesome. suppose I want see the all entered word in field then, how I change this code
			 
			
					
				Re: Last entered word in filed
				Posted: Tue Jun 14, 2016 1:45 pm
				by dunbarx
				Sorry.
 suppose I want see the all entered word in field then, how I change this code
I do not understand what you want.
Craig
 
			
					
				Re: Last entered word in filed
				Posted: Tue Jun 14, 2016 4:26 pm
				by Klaus
				Hi Shalu,
do you have any idea what Craig's script actually does?
Best
Klaus
			 
			
					
				Re: Last entered word in filed
				Posted: Wed Jun 15, 2016 5:57 am
				by shalu
				@dunbarx @Klaus sorry for the late reply
now the last entered word is placed into lastText "set the lastText of me to me", I want all word I entered into the field is placed into "lastText".
			 
			
					
				Re: Last entered word in filed
				Posted: Wed Jun 15, 2016 10:57 am
				by shalu
				samlpe video is attached, I think now you understand my requrement
			 
			
					
				Re: Last entered word in filed
				Posted: Wed Jun 15, 2016 3:18 pm
				by dunbarx
				Shalu.
I have seen your video, but I do not understand it.
But is this what you wanted":
Code: Select all
on keyDown tkey
   put tKey after me
   set the lastText of me to the lastText of me & tKey
   if tkey is space then put "" into me
end keyDown
on rawKeyDown tKey
   if tKey = 65362 then set the text of me to the lastText of me
   select after last char of me
 pass rawKeyDown
end rawKeyDown
Craig
 
			
					
				Re: Last entered word in filed
				Posted: Tue Jun 28, 2016 10:19 am
				by shalu
				@dunbarx sorry for the late reply
It's ok now but the problem is when I press up arrow tex field is display the all last entered words. suppose the last entered words are word1, word2, word3 (word1 space word2 space e.t.c). If I press up arrow then word3 should display and If I again press uparrow then word2 should display. now the current output is word1 word2 word3
			 
			
					
				Re: Last entered word in filed
				Posted: Tue Jun 28, 2016 4:13 pm
				by dunbarx
				Hmmm.
Are you saying you want to store each field entry separately when you hit the spacebar? That is, each time the field is cleared? And then recall those entries one-by-one when you hit the up arrow?
If so, then make a second field, a bit larger than the first. Change your field handler to this:
Code: Select all
on keyDown tkey
      put tKey after me
      if tkey is space then
       set the lastText of me to me & return & the lastText of me
      put "" into me
   end if
   put the lastText of me into fld 2
end keyDown
on rawKeyDown tKey
   if tKey = 65362 then 
   --your homework here
 pass rawKeyDown
end rawKeyDown
Now this will load your text snippets into both the custom property and the field so you can see it. You will want to think of a way to clear that property, I would imagine, and maybe add other required gadgetry.
@Jacque, please look the other way. OK? Good. Now, Shalu, tell me how you can, in the "rawKeyDown" handler, extract each line of the custom property, one by one. This is tricky, but should be fun.
@Jacque! I asked you to turn around please.
Craig