Script widgets: How to emit a message than can be managed in widget's script?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Script widgets: How to emit a message than can be managed in widget's script?
Hi all,
Does anyone know how to emit a message from a script widget that can be captured in the widget's script?
By this I mean emitting a message like 'textChanged' in text fields - where you can then edit the widget's code in the IDE to respond to the message?
Does anyone know if this is possible?
Many thanks
Stam
Does anyone know how to emit a message from a script widget that can be captured in the widget's script?
By this I mean emitting a message like 'textChanged' in text fields - where you can then edit the widget's code in the IDE to respond to the message?
Does anyone know if this is possible?
Many thanks
Stam
-
- Livecode Staff Member
- Posts: 192
- Joined: Thu Apr 18, 2013 2:48 pm
Re: Script widgets: How to emit a message than can be managed in widget's script?
Do
in the script widget script
Code: Select all
send "textChanged" to the owner of me
Re: Script widgets: How to emit a message than can be managed in widget's script?
Thanks Ali
I'm doing that already but was asking if it's possible to respond to the message inside the widget instead of it's owner, pretty much like textChanged would function in a field's script... I'm guessing no then
I'm doing that already but was asking if it's possible to respond to the message inside the widget instead of it's owner, pretty much like textChanged would function in a field's script... I'm guessing no then
Re: Script widgets: How to emit a message than can be managed in widget's script?
Wouldn’t that just be calling the handler directly? Are you wanting to do some work in the widget before passing the message for possible additional work outside?
Brian Milby
Script Tracker https://github.com/bwmilby/scriptTracker
Script Tracker https://github.com/bwmilby/scriptTracker
Re: Script widgets: How to emit a message than can be managed in widget's script?
No it's not the same.
If a certain action occurs, then a message would be emitted that can be captured by a developer in the widget's script to react to It,
As mentioned, the best analogy would be implementing a 'textChanged' handler in a text field. It is more practical to have this in the text field's script rather than the card script.
What Ali recommends is what Bernd recommended to me previously and what I've already implemented, and certainly works.
But you have to capture the message in the card script rather than the widget's (i.e. after adding to a card), which is like having a textChanged message in the card script that has to act based on the id of the text field that emitted the 'textChanged' message and the content of the message.
It works, but it's not the most practical/intuitive way of doing this...
But sounds like this probably isn't possible at present
Re: Script widgets: How to emit a message than can be managed in widget's script?
Ok, I understand now. You want an equivalent to the LCB
Code: Select all
post “messageName”
Brian Milby
Script Tracker https://github.com/bwmilby/scriptTracker
Script Tracker https://github.com/bwmilby/scriptTracker
-
- Livecode Staff Member
- Posts: 192
- Joined: Thu Apr 18, 2013 2:48 pm
Re: Script widgets: How to emit a message than can be managed in widget's script?
This isn't the intention- you are supposed to be able to handle the message in the widget object's script. I'll have to check but potentially this is a dp 5 bug which will be fixed in dp 6.
Re: Script widgets: How to emit a message than can be managed in widget's script?
Please ignore my previous statement - completely my error.livecodeali wrote: ↑Tue Aug 29, 2023 6:25 pmThis isn't the intention- you are supposed to be able to handle the message in the widget object's script. I'll have to check but potentially this is a dp 5 bug which will be fixed in dp 6.
While I had been handling the message in the card script perhaps misunderstanding Bernd's advice, I've finally had some time to check (day job getting in the way!) and it works perfectly in widget's script. I even get the option to add the handler from the left sidebar in the SE!
Loving script widgets even more!