Forcing a return/Carriage Return

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
arkstar
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 70
Joined: Mon Dec 21, 2009 1:51 am

Forcing a return/Carriage Return

Post by arkstar » Wed Sep 01, 2010 2:29 pm

I have a stack where the user can edit a message before sending off an email.
If the user hits the return key, it sends off the message. I would like pressing the return key to generate a linefeed or CR

I have used this code:

on returnInField
put return after me
end returnInField

This code does works but it sends the cursor to the bottom of the window and not to the next line.....

Any ideas?

Thanks
Rob
Rob Glassman
ArkStar

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: Forcing a return/Carriage Return

Post by dunbarx » Wed Sep 01, 2010 3:17 pm

I am not sure what distinguishes the two operations. But does this do what you want?

Code: Select all

on returnInField
   select after line word 2 of the selectedLine of me + 1 of me
end returnInField
You mentioned that you wanted to go to the next line. The previous script does that. But it does not add a return. If you want that:

Code: Select all

on returnInField
    put return after line word 2 of the selectedLine of me of me
end returnInField
And I assume that the mail is sent in another line of code somewhere.

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Forcing a return/Carriage Return

Post by Klaus » Wed Sep 01, 2010 3:27 pm

Hi arkstar,

you trigger a command/handler on RETURN in that field right?
But this is not in your "returninfeld" handler? So how do you do this?

Whatever, you could do this:

Code: Select all

on returnInField
  send "the_handler_that_needs_to_be_triggerd" to this stack in 1
  pass returninfield
end returnInField
This will wait 1 tick (= 1/60 second) before the action takes place,
so time enough for the field to put that CR automatically at the right place! :D
Know what I mean?


Best

Klaus

arkstar
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 70
Joined: Mon Dec 21, 2009 1:51 am

Re: Forcing a return/Carriage Return

Post by arkstar » Wed Sep 01, 2010 4:05 pm

Thanks guys for the FAST responses!

I used dunbarx's code and it worked perfectly!

Thanks so much!

Rob
(arkstar)
Rob Glassman
ArkStar

Post Reply