I have 1 stack with 3 substacks. On the main stack I have 1 card with 1 image and some buttons on that card.
This image can change by selecting it from file. This is done in one of the substacks and put into the main stack with right size and position.
In the scripts I call it: image 1
But when I click on a button in the substack, which has nothing to do with the image 1, I get a execution error "can't find handler", which is pointing to my image 1 in the main stack.
I don't understand this. Somehow the script is going back to the scripts in the main stack, but I don't see the reason why this happens.
Here is how the image is selected and put on the card of the main stack (navigator)
on mouseUp
global PadLogo
delete Image 1
answer file empty
import paint from file it
set the height of image 1 to 80
set the width of image 1 to 120
set the location of image 1 to 438,54
put it into PadLogo
## answer Padlogo
send "logo" of stack "Navigator"
end mouseUp
And here is the script which is triggered when I click on the button "new record" on substack "Portals" , which has nothing to do with image 1 in the main stack "Navigator".
This script opens a stack "Input" and goes to the selected card.
on mouseUp
If field "WhichButton" = 1 then
answer "Button Relaties is not yet operational"
else
If field "WhichButton" = 2 then
send "goToCardNewOrg" of stack "Input"
else
If field "WhichButton" = 3 then
send "goToCardNewPerson" of stack "Input"
end if
end if
end if
end mouseUp
Thanks
Rob van der Sloot
image 1 problem
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Livecode Opensource Backer
- Posts: 79
- Joined: Sat Apr 17, 2010 9:21 am
Re: image 1 problem
Dag Rob,
not sure what exactly your problem is, but here a revised version of your scripts,
please read the comments:
Best
Klaus
not sure what exactly your problem is, but here a revised version of your scripts,
please read the comments:
Code: Select all
on mouseUp
global PadLogo
## Always chgeck for errors!
## If you don't and there is one, a standalone will simply stop at that point in script!
if the num of images of this cd > 0 then
delete Image 1
end if
## Again, YOU have to take care that the user does not make any "grapjes" to make your scripts break! :-D
## Here we only let JPGs, PNG and GIF fiels appear in the open dialog:
answer file "Please select an image" with type "Iamges|jpg,png,gif|"
## Hint: DO not use IT unless neccessary!
## IT will change whenever you do not exspect IT :-D
put IT into tSelectedImage
## User may have clicked CANCEL!!!
## And you have to handle that situation!
if tSelectedImage = EMPTY then
exit mouseup
end if
import paint from file tSelectedImage
set the height of image 1 to 80
set the width of image 1 to 120
set the location of image 1 to 438,54
put tSelectedImage into PadLogo
## Just like regular MAIL, you send something TO something!
send "logo" TO stack "Navigator"
end mouseUp
Code: Select all
on mouseUp
## I avoid nested IF THENs wherever possible.
## I prefer SWITCH in these cases, which is much more readable
put fld "WhichButton" into tText
switch tText
case 1
answer "Button Relaties is not yet operational"
break
case 2
## TO TO TO TO! :-D
send "goToCardNewOrg" TO stack "Input"
break
case 3
send "goToCardNewPerson" TO stack "Input"
break
end switch
end mouseUp
What is in that script?But when I click on a button in the substack, which has nothing to do with the image 1, I get a execution error "can't find handler", which is pointing to my image 1 in the main stack.
Best
Klaus
-
- Livecode Opensource Backer
- Posts: 79
- Joined: Sat Apr 17, 2010 9:21 am
Re: image 1 problem
Thanks Klaus,
I took all your advice and it looks much better now.
What was missing in the script from where the problem started is that I did not first opened the sub stack: "Input" .
I added the line: set visible of stack "Input" to true. So the script is now looking very simple:
on mouseUp
put fld "WhichButton" into tText
set visible of stack "Input" to true
switch tText
case 1
answer "Button Relaties is not yet operational"
break
case 2
send "goToCardNewOrg" TO stack "Input"
break
case 3
send "goToCardNewPerson" TO stack "Input"
break
end switch
end mouseUp
All the best
Rob
I took all your advice and it looks much better now.
What was missing in the script from where the problem started is that I did not first opened the sub stack: "Input" .
I added the line: set visible of stack "Input" to true. So the script is now looking very simple:
on mouseUp
put fld "WhichButton" into tText
set visible of stack "Input" to true
switch tText
case 1
answer "Button Relaties is not yet operational"
break
case 2
send "goToCardNewOrg" TO stack "Input"
break
case 3
send "goToCardNewPerson" TO stack "Input"
break
end switch
end mouseUp
All the best
Rob
Re: image 1 problem
Dag Rob,
okie dokie
Groetjes
Klaus
okie dokie

Groetjes
Klaus