I am writing a script for a text field which will be completely editable, ie. a Journal Entry. I want to insert a Date-Time Stamp where ever the current insert point might be. It may not be at the end of the field, so
"Put the date & " " & the time after field 1" will not always work
Here is how I am trying to do it:
On returninfield
if the controlKey is down then
-- get the insertion point of this field
-- put the date & time into char it of this field
-- set the insertion point after this field
end if
pass returninfield
end returninfield
Thanks for your help.
Detecting and Setting Insertion Point in a field
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 3
- Joined: Sat Jan 09, 2010 4:28 pm
Re: Detecting and Setting Insertion Point in a field
Dear Curmudgeon,
Try the following:
Best,
Mark
Try the following:
Code: Select all
put the short date & comma && the short time after the selectedchunk
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
- Posts: 3
- Joined: Sat Jan 09, 2010 4:28 pm
Re: Detecting and Setting Insertion Point in a field
Okay, that helps some, The first part works; The date and time are inserted at the proper place.
Now the focus is set to the next field. Apparently under normal conditions [Cntrl - Enter] tabs to the next field.
Is there another handler that I need to intercept to prevent this from happening? I want to use the [Cntrl - Enter] combination simply because I have another application that I have used for years that inserts the Date-Time with [Cntrl - Enter], and old habits are hard to break.
Now the focus is set to the next field. Apparently under normal conditions [Cntrl - Enter] tabs to the next field.
Is there another handler that I need to intercept to prevent this from happening? I want to use the [Cntrl - Enter] combination simply because I have another application that I have used for years that inserts the Date-Time with [Cntrl - Enter], and old habits are hard to break.
-
- Posts: 3
- Joined: Sat Jan 09, 2010 4:28 pm
Re: Detecting and Setting Insertion Point in a field
Never mind!
I figured it out. I need to put the "pass returninfield" into an else statement.
on returninfield
if the controlKey is down then
put the seconds into dater
convert dater to dateitems
put item 2 of dater & "/" & item 3 of dater & "/" & item 1 of dater & " " & item 4 of dater & ":" & item 5 of dater & return after the selectedchunk
select after the last word of field "Notes"
else
pass returninfield
end if
end returninfield
BTW; How do you get the "Code: Select all" box to display the code?
I figured it out. I need to put the "pass returninfield" into an else statement.
on returninfield
if the controlKey is down then
put the seconds into dater
convert dater to dateitems
put item 2 of dater & "/" & item 3 of dater & "/" & item 1 of dater & " " & item 4 of dater & ":" & item 5 of dater & return after the selectedchunk
select after the last word of field "Notes"
else
pass returninfield
end if
end returninfield
BTW; How do you get the "Code: Select all" box to display the code?
Re: Detecting and Setting Insertion Point in a field
Hi Curmudgeon,
Write a script, select the text and click on the Code button just above the text field in which you're writing. This puts code tags around your script. You can also type the code tags manually.
Best,
Mark
Write a script, select the text and click on the Code button just above the text field in which you're writing. This puts code tags around your script. You can also type the code tags manually.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode