Behaviors

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Behaviors

Tom Glod via use-livecode
Hi all.

I've decided to start in on behaviors now as I have so much code that is effectively identical. So I took the code from a menu/button with a menuPick handler and put it in another button, then set the behavior of the first button to the long id of the second. I then set a breakpoint in the behavior script. I still have a menuPick handler in the first button to handle special case menu items for that card, but I commented out the code that is common between them.

The trouble is, selecting the menu item does not trigger the behavior. I tried setting pass menuPick in each one, but still no bueno. So which one gets the message first/at all? The behavior or the actual button?

Bob S



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Behaviors

Tom Glod via use-livecode
Bob,

Maybe the best way to do this is to use the before or after control structure in the behavior, rather than the menuPick.

before menuPick pItem
  # do common behavior stuff here
end menuPick

That leaves the menuPick handler unencumbered in the actual object.

Devin

On Sep 18, 2017, at 5:14 PM, Bob Sneidar via use-livecode <[hidden email]<mailto:[hidden email]>> wrote:

Hi all.

I've decided to start in on behaviors now as I have so much code that is effectively identical. So I took the code from a menu/button with a menuPick handler and put it in another button, then set the behavior of the first button to the long id of the second. I then set a breakpoint in the behavior script. I still have a menuPick handler in the first button to handle special case menu items for that card, but I commented out the code that is common between them.

The trouble is, selecting the menu item does not trigger the behavior. I tried setting pass menuPick in each one, but still no bueno. So which one gets the message first/at all? The behavior or the actual button?

Bob S



_______________________________________________
use-livecode mailing list
[hidden email]<mailto:[hidden email]>
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Devin Asay
Director
Office of Digital Humanities
Brigham Young University

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Behaviors

Tom Glod via use-livecode
Sorry, I should have said “Use 'before menuPick' or 'after menuPick' instead of ‘on menuPick’.


On Sep 18, 2017, at 5:21 PM, Devin Asay via use-livecode <[hidden email]<mailto:[hidden email]>> wrote:

Bob,

Maybe the best way to do this is to use the before or after control structure in the behavior, rather than the menuPick.

before menuPick pItem
 # do common behavior stuff here
end menuPick

That leaves the menuPick handler unencumbered in the actual object.

Devin

On Sep 18, 2017, at 5:14 PM, Bob Sneidar via use-livecode <[hidden email]<mailto:[hidden email]><mailto:[hidden email]>> wrote:

Hi all.

I've decided to start in on behaviors now as I have so much code that is effectively identical. So I took the code from a menu/button with a menuPick handler and put it in another button, then set the behavior of the first button to the long id of the second. I then set a breakpoint in the behavior script. I still have a menuPick handler in the first button to handle special case menu items for that card, but I commented out the code that is common between them.

The trouble is, selecting the menu item does not trigger the behavior. I tried setting pass menuPick in each one, but still no bueno. So which one gets the message first/at all? The behavior or the actual button?

Bob S



_______________________________________________
use-livecode mailing list
[hidden email]<mailto:[hidden email]><mailto:[hidden email]>
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Devin Asay
Director
Office of Digital Humanities
Brigham Young University

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Devin Asay
Director
Office of Digital Humanities
Brigham Young University

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Behaviors

Tom Glod via use-livecode
Hi Devin. That actually works a peach, thanks. I'm excited about going to behaviors, as I have a LOT of identical code in my app and this is going to streamling everything a great deal.

Bob S


> On Sep 18, 2017, at 16:23 , Devin Asay via use-livecode <[hidden email]> wrote:
>
> Sorry, I should have said “Use 'before menuPick' or 'after menuPick' instead of ‘on menuPick’.
>
>
> On Sep 18, 2017, at 5:21 PM, Devin Asay via use-livecode <[hidden email]<mailto:[hidden email]>> wrote:
>
> Bob,
>
> Maybe the best way to do this is to use the before or after control structure in the behavior, rather than the menuPick.
>
> before menuPick pItem
> # do common behavior stuff here
> end menuPick
>
> That leaves the menuPick handler unencumbered in the actual object.
>
> Devin
>

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode