Stacks, groups, and the target...

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Stacks, groups, and the target...

Post by bogs » Fri Apr 10, 2020 2:25 pm

I am trying to understand more about how the target works, and the message path in general.

I have a stack with 2 fields, and a grouped set of navigation buttons.
aPic_targets.png
I shot an arrow...and MISSED!
In the group script, I have the following..

Code: Select all

local lclClicked

on mouseDown
   put the short name of the target into lclClicked
   answer the target
   if character 1 to 3 of lclClicked is "cmd" then set the lineSize of the target to 3
end mouseDown
I would think the 'answer the target' line wouldn't fire outside of the objects in the group, but apparently it does, is there a reason why? There are no other target statements outside of the group, and if the click is outside of the group, how is it triggering a script inside the group?

Thank you for any input.
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Stacks, groups, and the target...

Post by richmond62 » Fri Apr 10, 2020 2:47 pm

what.png
-
So; I made a very stupid stack which has 3 buttons in a group called "TARGE".

the group "TARGE" contains this script:

Code: Select all

on mouseUp
   put "You Clicked me!"
end mouseUp
Now, when I click inwith the group but outwith any of its constituent buttons I get NO response.

When I click on one of the buttons I get "You Clicked Me!" in the MessageBox.

Stack here: https://www.dropbox.com/s/obx1qg2j4wk3b ... e.zip?dl=0

Where did I misunderstand your post?

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Stacks, groups, and the target...

Post by bogs » Fri Apr 10, 2020 3:05 pm

Heh, apparently I wasn't clear enough on the question :)

If you look at the picture of the stack I put up, the buttons on the bottom of the stack are grouped (small area, group rect is the size of the buttons combined rect, not the whole stack).

Now, within the script of the group, I have the line -
answer the target

Since that line is within only the group script, I would like to know why I get an answer dialog no matter where I click, inside or outside of the group. I would think I would only see the dialog clicking on something inside the group rect itself.

Additional information that may (or may not) be important - the fields outside of the group are locked and transversal is off, so they behave much like a button.
Image

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Stacks, groups, and the target...

Post by Klaus » Fri Apr 10, 2020 3:13 pm

Did you take a look at Richard's nice article?
http://www.fourthworld.com/embassy/arti ... _path.html

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Stacks, groups, and the target...

Post by bogs » Fri Apr 10, 2020 3:27 pm

Yes, many times previously and just now again, thinking I had missed something. According to this graphic from that article -
Image
I would think my reasoning is sound. I am getting 'the target' from an input event (mouseDown) inside of a group.

If I click on a control outside of that group, I'm not sure why the message should be picked up by the group. It would seem bizarre if you are saying that because there is a group anywhere in a program, it's scripts will fire on any event when you haven't interacted with it.

I think I did finally see the reason because of that graphic, though, and my reasoning was perhaps too narrow. Since the group is also set to be a background, I guess that might be the reason (although it still strikes me bizarre).

Anyway, I finally added a work around to make sure I was getting the target only from the group -

Code: Select all

   if the loc of the target is within the rect of group "grpNavigation" then
      put the short name of the target into lclClicked
      --answer lclClicked
   end if
Although sufficient and working, I'd still like to know how to not get this result the correct way.
Image

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Stacks, groups, and the target...

Post by bogs » Fri Apr 10, 2020 3:40 pm

Never mind, it was my understanding that was incorrect, I found the explanation of why here.
Image

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Stacks, groups, and the target...

Post by Klaus » Fri Apr 10, 2020 3:40 pm

Get used to it, this is a FEATURE! :D

You can also use "the owner":

Code: Select all

...
if the short name of the owner of the target = "grpNavigation" then
...

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Stacks, groups, and the target...

Post by bogs » Fri Apr 10, 2020 3:45 pm

Easier to just turn off the background behavior property, for me personally. I can paste the thing onto every next card :evil:
Image

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10049
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Stacks, groups, and the target...

Post by FourthWorld » Fri Apr 10, 2020 3:59 pm

bogs wrote:
Fri Apr 10, 2020 3:45 pm
Easier to just turn off the background behavior property, for me personally. I can paste the thing onto every next card :evil:
No need to replicate the group. The backgroundBehavior and sharedBehavior properties were separated a few years back, so you can have a group that's shared among cards without the HC-styled message path alteration.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Stacks, groups, and the target...

Post by bogs » Fri Apr 10, 2020 4:09 pm

I realize now I should have said "place'', not "paste", i.e. "Go to the card you want the group to be on and choose the group from the Place Group menu item on the Object menu", but thank you for chiming in :)
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Stacks, groups, and the target...

Post by richmond62 » Fri Apr 10, 2020 4:59 pm

OK, OK, I shall deliberately ignore ALL between my last posting and this one. :wink:

Now, when I put this into my group's script:

Code: Select all

on mouseUp
   put the target
end mouseUp
When I click on an object inwith the group that script fires and puts the name of the object inwith the group on which I clicked intil the MessageBox.

When I click intil the group but outwith the bounds of any objects contained inwith the group nothing happens.

THAT seems to be what you are aiming at. 8)

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Stacks, groups, and the target...

Post by bogs » Fri Apr 10, 2020 5:11 pm

Heh, the correct answer was "Stop setting the group as a background, you dolt!"
Image

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Stacks, groups, and the target...

Post by Klaus » Fri Apr 10, 2020 5:18 pm

Oh my, Richmond, you are a hopeless case! :D

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Stacks, groups, and the target...

Post by bogs » Fri Apr 10, 2020 5:29 pm

I think he is just adorable haha.
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Stacks, groups, and the target...

Post by richmond62 » Fri Apr 10, 2020 5:38 pm

the correct answer
The problem with that statement was 'the' as we all know with LiveCode there is almost always more than
one answer to everything.

So, maybe a 'dolt', but not a bigot. 8)

Post Reply