Onload events or openCard
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 339
- Joined: Wed Jul 11, 2012 9:24 pm
Onload events or openCard
Does LiveCode have any onload events? I want to load an image from the Internet but I don't want to connect it to a button. I want it to automatically load. I looked at OpenCard - but either that isn't the solution or I am putting OpenCard in the wrong spot - because it doesn't work. I was trying a simple test of putting "bob" in a text field with OpenCard and it didn't work either.
on openCard
put "bob" into field "sample text"
end openCard
Sorry for being so dumb.
on openCard
put "bob" into field "sample text"
end openCard
Sorry for being so dumb.
Re: Onload events or openCard
Hmmm... Nothing wrong with your openCard handler. I take it "bob" isn't going into the field? And that field exists on the card?
Where did you put the openCard handler? You might try something like this to ensure that it's getting called
Where did you put the openCard handler? You might try something like this to ensure that it's getting called
Code: Select all
on openCard
answer "openCard!" && the name of this card
end openCard
Re: Onload events or openCard
You need to make sure that messages are not turned off. (look at the toolbar see if the messages icon to see if messages are enabled or disabled)
Then make sure your script is either in the card script or the stack script. From the dictionary:
If the opencard handler is in an object it will never fire (unless you explicitly send the opencard message to the object yourself)
And of course if the card is already open when you enter the script, since it is already open the script won't fire.
Then make sure your script is either in the card script or the stack script. From the dictionary:
So when it is sent to the card, if there is an opencard handler there it will execute. If there is NO opencard handler, the message will go up the message path to the stack and look for a handler there.Sent to a card right after you go to the card.
If the opencard handler is in an object it will never fire (unless you explicitly send the opencard message to the object yourself)
And of course if the card is already open when you enter the script, since it is already open the script won't fire.
Re: Onload events or openCard
Hi,
the script DOES of course work!
Where did you put it?
As the name suggest, best to put it into the CARD script.
Check this great overview about the message hierarchie in LiveCode:
http://www.fourthworld.com/embassy/arti ... _path.html
Or am I misunderstanding you?
Best
Klaus
the script DOES of course work!

Where did you put it?
As the name suggest, best to put it into the CARD script.
Check this great overview about the message hierarchie in LiveCode:
http://www.fourthworld.com/embassy/arti ... _path.html
Or am I misunderstanding you?
Best
Klaus
-
- Posts: 339
- Joined: Wed Jul 11, 2012 9:24 pm
Re: Onload events or openCard
It works now. I think one of the problems I have had is that I've been using multiple versions of my application with the same names - without using "File" - "Close and remove from memory". Now that I am being more careful to only have one open at a time, I am having fewer problems.
Thanks
Thanks
Re: Onload events or openCard
Well... 
