field changed message
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
field changed message
Hi: there is probably a simple way of doing this, but I can't seem to figure it out. I want a handler in the script of a field that does something when the content of the field has changed. I don't really want to set up a loop to check for a change - unless i have to I guess. The user does NOT change this field. It's contents are streamed from a port.
Thanks!
Greg
Thanks!
Greg
Re: field changed message
There are a couple options. There is the textchanged message that will trigger even with programmatic text changes to the field. Though I'm not sure its necessary because if you're reading from a port and putting new content into the field, you could manually call a handler right after you add the text to the field.
Either method should work.
Either method should work.
Code: Select all
on textchanged
## do something
end textchanged
-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
Re: field changed message
Thanks. When I search for "textChanged" it is not found in the dictionary
Re: field changed message
textChanged is a recent addition. What version of livecode are you running? There are some more recent versions where it is available but not yet in the dictionary, though I think the most recent does show textChanged.
-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
Re: field changed message
Yep, it should be there. (though you can get 5.5.2 now)
To test, create a field and put the following in its script.
As you type in the field it should echo the contents to the message box. (the first char you type might shift focus to the msg box so you'll have to click back into the field)
Heres most of the 5.5.2 dictionary entry..
To test, create a field and put the following in its script.
Code: Select all
on textChanged
put the text of me
end textChanged
Heres most of the 5.5.2 dictionary entry..
Summary:
Sent when the content of a field has changed.
Examples:
on textChanged -- enable the save button when a change is made
enable button "save"
end textChanged
Is dispatched by the field whenever a user (or simulated user) action causes the content of the field to change.
Comments:
Handle the textChanged message if you want to perform an action when the content of a field changes.
The message is sent immediately after the input operation completes, but before a screen update is requested. The corresponding update occurs at the end of the first command in the textChanged handler. This means that you can lock the screen at the first line of the handler to delay the screen update (allowing you to modify the content of the field without any flicker).
To prevent potential for infinite recursion, calls to textChanged do not nest. Once a textChanged handler is being executed for a given field, another textChanged message is not sent to it, should a subsequent one be triggered.
The textChanged message is sent after messages such as keyDown and pasteKey but before messages such as keyUp.
-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
Re: field changed message
Hi: The TextChanged handler doesn't work in my case because I am changing the fields contents with a script, and not by TYPING into the field. This handler only works when the field has been entered, and then contents changed.
Re: field changed message
I might do as follows:
in data packed systems, I generally find it helpful to pass gui-targeted values through arrays.
hth,
Code: Select all
- put field id (i) into tHistory[i]
- put the_external_value into field[i]
- if tHistory[i] <> field id (i) then answer "the value has changed!"
hth,
Tim
Re: field changed message
Interesting. I could have sworn one of the recent versions of lc had a textchanged that would respond to script changes.
And this line
seems to indicate that it still should.
However if you look at the earlier answers there is this..
Not sure I see a problem here even though the textchanged doesn't work as expected.
And this line
Code: Select all
Is dispatched by the field whenever a user [b](or simulated user) action[/b] causes the content of the field to change.
However if you look at the earlier answers there is this..
Meaning..Though I'm not sure its necessary because if you're reading from a port and putting new content into the field, you could manually call a handler right after you add the text to the field.
Code: Select all
on handlerthatchangesthefield
do stuff here
do more stuff
-- run the command for when the field contents change
myFieldChanged --
end handlerthatchangesthefield
command myFieldChanged
do whateve you need done when the field changes
end myFieldChanged
Not sure I see a problem here even though the textchanged doesn't work as expected.
-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
Re: field changed message
Thanks - there isn't really a big problem with adding my text changed stuff to the handler that reads from the port and writes to the field. That works fine, and might be the fastest way of doing it. However, there *may* be times when the port isn't working (data server streaming to the port is down), and I may want to provide some other method of writing data to that field aside from reading from the port. In this case, my handler to act upon a change in the contents of the field (if delt with in the port writing handler) won't work, and would need to be duplicated - which is what I'm trying to avoid. But... I could just write a handler to handle it - or a function. And just call the function in the port handler - and the same functioon from any new thing I have to write.
Re: field changed message
I read it the same way but yeah, "putting" text into a field doesn't do it. Apparently "user simulated" changes means simulated typing. I see that the "type" command does trigger a textchanged message.sturgis wrote:Interesting. I could have sworn one of the recent versions of lc had a textchanged that would respond to script changes.
Interesting.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 738
- Joined: Thu Sep 11, 2014 1:49 pm
Re: field changed message
Still does not work in version 7.06 if I enter a value in a field from a script. 
I will solve it with a handler ...

I will solve it with a handler ...
Re: field changed message
why don't you send "textChanged" after you field changing script is done?Still does not work in version 7.06 if I enter a value in a field from a script.
I will solve it with a handler ...
Code: Select all
on mouseUp
put "asldfkj" after field "input"
send "textChanged" to field "input"
end mouseUp
Bernd