Page 1 of 1
on openCard, is there a bug?
Posted: Thu Nov 04, 2021 4:27 pm
by Joop Sleijster
Hello,
I have a Stack with 3 Cards.
Card 1 with a Button “Go Next” + script
Card 2 with a Button “Go First” + script
Card 3 with a Button “Go First” + script
Card 2 with Card script:
On openCard
go next
End openCard
This Card 2 script is always executed when the card is opened, both in Run mode and Edit mode.
It should not in Edit mode, isn’t it?
The only way to open card 2 is to double click on Script lines in the Project Browser so the code window of card 2 opens and then comment out the script.
I use LC 9.6.4 Indy
Is this a bug?
thanks
Joop
Re: on openCard, is there a bug?
Posted: Thu Nov 04, 2021 4:44 pm
by Klaus
Dag Joop,
I don't think this is a bug, but a feature! I recently had to learn this for "mouseenter"
which is also sent with the pointer tool!
The message "opencard" is being triggered and sent and that is desired behavior.
I once created a small palette for e.g. to navigate through my stack(s).
I used this script for the "Next" button:
Code: Select all
on mouseup
if the ALTkey = "down" then
lock messages
end if
go next cd
end mouseup
So you could just use the message box:
Groetjes
Klaus
Re: on openCard, is there a bug?
Posted: Thu Nov 04, 2021 10:07 pm
by xAction
Trap the currentCard like so
You fill in the actual name between <>
Code: Select all
on openCard
if the currentCard of this stack is not <"the short name of the target card"> then exit openCard
end openCard
Using the number of the currentCard instead of short name of 'currentCard'
Code: Select all
on openCard
if the number of the currentCard of this stack is not 2 then exit openCard
end openCard
OpenStack, openCard, resizeStack...get sent to everything all at once. I've had so many nightmares with that. But exiting at the top of the handler if the message is not intended for that object seems to be the workable solution.
I'm not sure if using 'private' will control who gets the message and who doesn't
Let's test
uh, I don't know what 'private' is doing.
Code: Select all
private on openCard
put the number of the currentCard of this stack into fld 1
end openCard
doesn't do anything at all card after card
sending openCard through the message box does what is intended.
Re: on openCard, is there a bug?
Posted: Fri Nov 05, 2021 9:51 am
by stam
Joop Sleijster wrote: ↑Thu Nov 04, 2021 4:27 pm
It should not in Edit mode, isn’t it?
I think that is intended as it not a bug.
If you want to be able to navigate in edit mode without triggering the 'go next' statement, then you can add a conditional:
Code: Select all
on openCard
if the tool is "browse tool" then go next
end openCard
This will then only run when you're running the app.
S.
--- edited to correct the typo of the forgotten 'if'

(thanks Jacque!)
Re: on openCard, is there a bug?
Posted: Fri Nov 05, 2021 6:26 pm
by jacque
Stam's solution is what I do, though the second line is missing the "if". It's a typo.
Re: on openCard, is there a bug?
Posted: Sat Nov 06, 2021 9:33 pm
by Joop Sleijster
Hi,
Thank you all for your responses.
It's completely clear to me.
However, I still don't understand the purpose of the “open card” message in Edit mode.
If you go to the card to edit the card in edit mode, that's not very handy in my opinion.
But your responses helped me a lot.
thanks,
joop
p.s.
Dag Klaus
The salutation and conclusion of your response was perfectly Dutch.
Groetjes,
j.
Re: on openCard, is there a bug?
Posted: Sat Nov 06, 2021 11:01 pm
by stam
Joop Sleijster wrote: ↑Sat Nov 06, 2021 9:33 pm
However, I still don't understand the purpose of the “open card” message in Edit mode.
openCard and preOpenCard are often used for initialisation of layout and data when entering a card. In these cases, it's good that it works in edit mode, otherwise you'd have to enter browse mode, navigate to the card (or run pre/openCard from the msg box) and then enter edit mode - tedious.
For example i have a stack where a styled field top left informs the user which section (card) they're on. I've named the cards to reflect this name and have a background group containing this field, so it exists on all new cards i create. I just set the text of the field to be the short name of the card when navigating to said card and it's all automatic even in edit mode, which is useful...
Re: on openCard, is there a bug?
Posted: Sun Nov 07, 2021 4:11 pm
by Klaus
Dag Joop.
Joop Sleijster wrote: ↑Sat Nov 06, 2021 9:33 pm
...
p.s.
Dag Klaus
The salutation and conclusion of your response was perfectly Dutch.
Groetjes,
j.
Dat weet ik heel goed, ik spreek een beetje nederlands.

Tot ziens!