Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
japino
- Posts: 78
- Joined: Sun Oct 14, 2012 10:56 am
Post
by japino » Wed Oct 31, 2012 1:11 pm
I have a field which has this field script:
Code: Select all
on textChanged
send mouseup to btn "Update" of stack "My list"
end textChanged
Any changes I apply to this field, for example typing text, can not be undone by selecting "Undo" from the Edit menu. "Undo" works fine for other fields. Can I have a field with an "on textChanged" handler and still use "Undo" for that field?
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10330
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Wed Oct 31, 2012 8:51 pm
Hi.
I have no problem with this. There must be something else you are doing. To test, I made the two objects you describe. In the button script, I simply said:
put fld 1 --the field with the "textChanged" handler
When I type into the field, the field text appears in msg. When I undo, the last typed text is removed from the field, and also from msg.
Craig Newman
Last edited by
dunbarx on Thu Nov 01, 2012 4:07 am, edited 1 time in total.
-
japino
- Posts: 78
- Joined: Sun Oct 14, 2012 10:56 am
Post
by japino » Wed Oct 31, 2012 10:18 pm
Thanks for your reply! I don't know what to say, it does not work for me. Undo does not work when I have the code in my field. When I comment out the code in the field, Undo works. I have nothing else in the field script, nothing in the card script, and only a closeStack handler in the stack script.

I'm using 5.5.3 on a Mac.
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10330
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Thu Nov 01, 2012 3:32 am
If you duplicate what I did, from scratch, do you get the same behavior I do?
-
japino
- Posts: 78
- Joined: Sun Oct 14, 2012 10:56 am
Post
by japino » Thu Nov 01, 2012 9:48 am
Yes, I do. So it does work with a new stack. But it beats me why it doesn't work with my original stack. I only have that script in the field and when I comment the script out, it works. I now suspect that there might be an issue with my script in the "Update" button which somehow prevents Undo from working? Hmmm, weird stuff. Anyway, thanks, this was helpful!
-
japino
- Posts: 78
- Joined: Sun Oct 14, 2012 10:56 am
Post
by japino » Thu Nov 01, 2012 4:24 pm
My Update button script looks like this (cleaned up a bit to only show the essential parts):
Code: Select all
on mouseUp
put empty into field "ToDo"
repeat with x = 1 to the number of cds of stack "MainApplication"
put field "ProjectID" of cd x of stack "MainApplication" & " - " & field "ProjectName" of cd x of stack "MainApplication" & return after field "ToDo"
repeat with y = 1 to the number of buttons of cd x of stack "MainApplication"
put name of button y of cd x of stack "MainApplication" into myButtonName
put (the number of chars of myButtonName)-1 into myNumberofChars
if char myNumberofChars of myButtonName = "•" then
if the enabled of btn myButtonName of cd x of stack "MainApplication" and not the hilite of btn myButtonName of cd x of stack "MainApplication" then put myButtonName & return after field "ToDo"
end if
end repeat
put field "Other" of cd x of stack "MainApplication" & return after field "ToDo"
put return after field "ToDo"
end repeat
end mouseUp
I'm guessing that when you select "Undo" my application tries to undo actions performed by this script instead of trying to undo the input typed by the user. When I comment out this essential part of the script, Undo works as expected.
Now beating my brain to get Undo to work while still performing the actions from this script...
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10330
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Fri Nov 02, 2012 5:53 am
Hi.
The offending line is:
put return after field "ToDo"
Comment it out, and all is well. You may just be undoing the return, which may not have any apparent effect. But I understand from the dictionary that script invoked actions are not undoable, only user actions.
This needs more study.
Craig Newman
-
japino
- Posts: 78
- Joined: Sun Oct 14, 2012 10:56 am
Post
by japino » Fri Nov 02, 2012 9:25 am
Thanks Craig. I tried it out, but just commenting out that line does not solve the issue. I need to comment out every line where the put command puts something into the field before Undo start working the way I want.
I will study more.

-
jacque
- VIP Livecode Opensource Backer

- Posts: 7393
- Joined: Sat Apr 08, 2006 8:31 pm
-
Contact:
Post
by jacque » Fri Nov 02, 2012 8:04 pm
You could try a little hack. Use the "type" command instead of "put". That simulates a user action.
On second thought though, it will make your script very slow. You could set the typingRate to something fast, maybe that would help, but it probably won't be perfect.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com