Assigning behaviors to cards
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Assigning behaviors to cards
I'm writing a quiz-generating program and for each question, a new card is created of one of just a few types.
I'd like to assign cards a behavior from a stock collection rather than cloning cards with the same behavior (especially since this will let me update code efficiently)
However, when I use
set the behavior of this card to btn "clickTuteCard_script" of card "Behaviors" of stack "ext_Behaviors"
nothing seems to happen. This syntax & location works for assigning behaviors to fields.
I notice that when inspecting objects, there is a field showing what behavior is set for that object.
I can't find such a field for cards
The dictionary includes 'card' as an assignable target for behaviors.
Can anybody see what I'm doing incorrectly or tell me where to look for a card's assigned behavior?
Thanks!
Bruce
I'd like to assign cards a behavior from a stock collection rather than cloning cards with the same behavior (especially since this will let me update code efficiently)
However, when I use
set the behavior of this card to btn "clickTuteCard_script" of card "Behaviors" of stack "ext_Behaviors"
nothing seems to happen. This syntax & location works for assigning behaviors to fields.
I notice that when inspecting objects, there is a field showing what behavior is set for that object.
I can't find such a field for cards
The dictionary includes 'card' as an assignable target for behaviors.
Can anybody see what I'm doing incorrectly or tell me where to look for a card's assigned behavior?
Thanks!
Bruce
Re: Assigning behaviors to cards
Hi Bruce,
1. welcome to the forum!
2. this line from the dictionary might help you out:
...
set the behavior of XXX to the long id of button "Widget" of card "Behaviors"
## "boldification" by me
...
Best
Klaus
1. welcome to the forum!

2. this line from the dictionary might help you out:
...
set the behavior of XXX to the long id of button "Widget" of card "Behaviors"
## "boldification" by me

...
Best
Klaus
Re: Assigning behaviors to cards
Klaus:
Thanks for the welcome & the suggestion!
Unfortunately, I get the same result--no error, but no evidence that the behavior has been attached. The right-click menu for the card doesn't still has "run card script" dimmed out also.
As I said, what is most worrisome is that I can't find evidence that there is a way to INSPECT an assigned behavior for cards; it's right there in the 'Object inspector' under 'Basic Properties' for other objects, but no such indication in the Card Inspector.
Does anybody have any reason to believe it's not just an overstatement in the docs?
Cheers
Bruce
Thanks for the welcome & the suggestion!
Unfortunately, I get the same result--no error, but no evidence that the behavior has been attached. The right-click menu for the card doesn't still has "run card script" dimmed out also.
As I said, what is most worrisome is that I can't find evidence that there is a way to INSPECT an assigned behavior for cards; it's right there in the 'Object inspector' under 'Basic Properties' for other objects, but no such indication in the Card Inspector.
Does anybody have any reason to believe it's not just an overstatement in the docs?
Cheers
Bruce
Re: Assigning behaviors to cards
No, unfortunately the property inspector hasn't kept up with the times. The way to set and view behaviors is with the message box. And you need to use the long id of an object when setting the behavior.
Code: Select all
set the behavior of this card to THE LONG ID OF btn "clickTuteCard_script" of card "Behaviors" of stack "ext_Behaviors"
put the behavior of this card
Re: Assigning behaviors to cards
Update: I finally read Klaus' reply and see that he already mentioned the long id thing. 

Your genius/my idiocy...
Ah, but the "put the behavior" check was useful.
It showed that the behavior was indeed getting attached.
This lead to the discovery that the button's behavior was blank
Thanks to you both--I'm hummin' along again!
Bruce
It showed that the behavior was indeed getting attached.
This lead to the discovery that the button's behavior was blank

Thanks to you both--I'm hummin' along again!
Bruce
-
- Posts: 919
- Joined: Wed Nov 04, 2009 11:41 am
Re: Assigning behaviors to cards
Hi,
I am attempting to assign a button that resides on a sub stack as a behavior to a card on the main stack. I have tried all the permutations I can think of but still I am unable to get the behavior to assign. I have tried the code below and using the message box as well as numeric ids all to no avail . Any suggestions?
I am attempting to assign a button that resides on a sub stack as a behavior to a card on the main stack. I have tried all the permutations I can think of but still I am unable to get the behavior to assign. I have tried the code below and using the message box as well as numeric ids all to no avail . Any suggestions?
Code: Select all
put "ListOfFieldsCard_Behavior" into tButton
put "Object Behaviors" into tStack
set the behavior of this stack to the long id of btn tButton of card id 1002 of stack tstack
best wishes
Skids
Skids
-
- Posts: 919
- Joined: Wed Nov 04, 2009 11:41 am
Re: Assigning behaviors to cards
Hmmm,
Given the power and importance of behaviors the ide still treats them as a bit of a bodge : some inspector panes show the behavior others do not. I totally failed to assign the behavior stored on a sub stack to a card on the main stack as described above.
This was annoying but nothing to what happened next: the behavior included an on opencard script and somehow it became assigned to a number of the other cards in my stack (but not the one I intended). The opencard call in the behavior made no sense with these cards and multiple errors were posted. Trying to remove the behavior using the message box was not effective so I had to delete the behavior button. Even this was difficult as it refused to delete; I think because there were probably pending calls in error but who knows, in the end I killed it.
Several projects saves and restarts later I went to copy another button and on the paste the first long deleted behavior button reappeared. All very odd, probably a bug but not one I have the strength to write up. In the end I reverted to placing my behavior button on a card in the same stack and the assignment worked.
<Rant>
I think that the inspector of every object that may have a behavior assigned should have a behavior pane that clearly shows the name and location of the behavior button i.e its long id rather than the truncated version that is sometimes displayed at present. Also the pane should allow the navigation through the loaded stacks to the behavior button and allow the behavior to be dropped or disabled. <rant\>
There I feel better now!
Thanks for reading.
best wishes
Simon K
Given the power and importance of behaviors the ide still treats them as a bit of a bodge : some inspector panes show the behavior others do not. I totally failed to assign the behavior stored on a sub stack to a card on the main stack as described above.
This was annoying but nothing to what happened next: the behavior included an on opencard script and somehow it became assigned to a number of the other cards in my stack (but not the one I intended). The opencard call in the behavior made no sense with these cards and multiple errors were posted. Trying to remove the behavior using the message box was not effective so I had to delete the behavior button. Even this was difficult as it refused to delete; I think because there were probably pending calls in error but who knows, in the end I killed it.
Several projects saves and restarts later I went to copy another button and on the paste the first long deleted behavior button reappeared. All very odd, probably a bug but not one I have the strength to write up. In the end I reverted to placing my behavior button on a card in the same stack and the assignment worked.
<Rant>
I think that the inspector of every object that may have a behavior assigned should have a behavior pane that clearly shows the name and location of the behavior button i.e its long id rather than the truncated version that is sometimes displayed at present. Also the pane should allow the navigation through the loaded stacks to the behavior button and allow the behavior to be dropped or disabled. <rant\>
There I feel better now!
Thanks for reading.
best wishes
Simon K
best wishes
Skids
Skids