How to detect changed text in a field?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
How to detect changed text in a field?
Hello,
I need to detect (event) when the text in a field is changed, but I cannot find any event like "on changeField" or similar.
Is there any way to do this?
Thank you!
I need to detect (event) when the text in a field is changed, but I cannot find any event like "on changeField" or similar.
Is there any way to do this?
Thank you!
-
- VIP Livecode Opensource Backer
- Posts: 1236
- Joined: Sat Apr 08, 2006 1:10 pm
- Location: Zurich
- Contact:
Most likely you do not really want the closeField messsage, but you want to vote for bug 5888
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
-
- VIP Livecode Opensource Backer
- Posts: 1236
- Joined: Sat Apr 08, 2006 1:10 pm
- Location: Zurich
- Contact:
Of course you have to create an account. That's the official revolution bug database, and i think your account email has to match the one you supplied when you bought your rev version.
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
...and until this has been implemented you WILL likely want to use "closefield"BvG wrote:Most likely you do not really want the closeField messsage, but you want to vote for bug 5888
-
- VIP Livecode Opensource Backer
- Posts: 9834
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
While the requested message would add a novel convenience to my my work, I can't say its absence would be cause for "anger", or really anything beyond the most mild annoyance, if even that.
After building apps in a variety of languages without such a message for 20 years, I'm confident al870 can find a suitable solution with acceptable effort if only he would take a moment to explain what it is he actually wants to do.
After building apps in a variety of languages without such a message for 20 years, I'm confident al870 can find a suitable solution with acceptable effort if only he would take a moment to explain what it is he actually wants to do.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Hello,
of course, I can find a worksround (no problem), but if that message was existing, then it could simplify my job
Since I'm new to Rev Studio, can you give me an hint to solve this problem (I say that I have a workaround, but I don't like it, so you could give me a better solution).
Basically, I have a small rev program with three buttons and one field (this is the field where I wnated to use that message!).
LAYOUT:
[BUTTON 1] [BUTTON 2] [BUTTON 3]
[
myField
]
Well, at the first time I made a different http request (GET) on every button and I putted the result in the field (not as html, since I'm working getting xml data, so I used plain text).
Well, now I decided to clean up the field as first operation. I didn't want to edit every button to change the code....
OLD BUTTON CODE:
NEW CODE COULD BE:
Well, since I didn't want to edit every button, I decided to use the (non existing message) to "intercept" myField modification (caused by "put url ......") and, in such event (inside the field self), delete the field and then "propagate" the event to receive new value. Here how that code could be (inside "myField"):
In this way I could simply modify an event, instead all buttons.
Even if it seems an excercise, I think it could be very interesting!
Thank you for your help!
of course, I can find a worksround (no problem), but if that message was existing, then it could simplify my job
Since I'm new to Rev Studio, can you give me an hint to solve this problem (I say that I have a workaround, but I don't like it, so you could give me a better solution).
Basically, I have a small rev program with three buttons and one field (this is the field where I wnated to use that message!).
LAYOUT:
[BUTTON 1] [BUTTON 2] [BUTTON 3]
[
myField
]
Well, at the first time I made a different http request (GET) on every button and I putted the result in the field (not as html, since I'm working getting xml data, so I used plain text).
Well, now I decided to clean up the field as first operation. I didn't want to edit every button to change the code....
OLD BUTTON CODE:
Code: Select all
put url "http://........." into field "myField"
Code: Select all
put empty into field "myField"
put url "http://........." into field "myField"
Code: Select all
on changedField
put empty into field "myField"
pass changedField
end changedField
Even if it seems an excercise, I think it could be very interesting!
Thank you for your help!
-
- Livecode Opensource Backer
- Posts: 86
- Joined: Thu May 17, 2007 9:15 pm
- Location: Maryland, USA
- Contact:
The CloseField event is mainly to detect when the USER has made a change to a field. If the code of the project is changing the field, then the code of the project should know that the field is changing.
That said, if you want to centralize the placement of data in a field and the execution of code that uses that data, then the best bet is to create a command at the Card or Stack level that does both:
And put a UpdateField command in each field you want to control in this way:
Then wherever you want to set the field, don't set it directly, use the command:
I haven't compiled, run, or otherwise tested any of this code, but it seems clean to me at first glance.
The benefits are:
- Just one command to set any field
- If that field doesn't have a custom UpdateField command, nothing else happens
- Each field can have it's own custom behavior
- You can, at any time, change either a field's custom behavior or the overall command's behavior, without having to modify any code where the calls originate from
That said, if you want to centralize the placement of data in a field and the execution of code that uses that data, then the best bet is to create a command at the Card or Stack level that does both:
Code: Select all
on SetFieldAndUpdate theField, theValue
set the text of fld theField to theValue
if theValue is not equal to the lastText of fld theField then
set the lastText of fld theField to theValue
send UpdateField to fld theField
end if
end SetFieldAndUpdate
Code: Select all
on UpdateField theValue
-- do your triggered event here
end UpdateField
-- and in case the USER changes the field...
on CloseField
SetFieldAndUpdate short name of me, text of me
end CloseField
Code: Select all
SetFieldAndUpdate "myField", myDataVar
The benefits are:
- Just one command to set any field
- If that field doesn't have a custom UpdateField command, nothing else happens
- Each field can have it's own custom behavior
- You can, at any time, change either a field's custom behavior or the overall command's behavior, without having to modify any code where the calls originate from
~ Nonsanity
~ Chris Innanen
~ Chris Innanen