Page 1 of 2

Stacks, groups, and the target...

Posted: Fri Apr 10, 2020 2:25 pm
by bogs
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.

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

Posted: Fri Apr 10, 2020 2:47 pm
by richmond62
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?

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

Posted: Fri Apr 10, 2020 3:05 pm
by bogs
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.

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

Posted: Fri Apr 10, 2020 3:13 pm
by Klaus
Did you take a look at Richard's nice article?
http://www.fourthworld.com/embassy/arti ... _path.html

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

Posted: Fri Apr 10, 2020 3:27 pm
by bogs
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.

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

Posted: Fri Apr 10, 2020 3:40 pm
by bogs
Never mind, it was my understanding that was incorrect, I found the explanation of why here.

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

Posted: Fri Apr 10, 2020 3:40 pm
by Klaus
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
...

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

Posted: Fri Apr 10, 2020 3:45 pm
by bogs
Easier to just turn off the background behavior property, for me personally. I can paste the thing onto every next card :evil:

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

Posted: Fri Apr 10, 2020 3:59 pm
by FourthWorld
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.

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

Posted: Fri Apr 10, 2020 4:09 pm
by bogs
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 :)

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

Posted: Fri Apr 10, 2020 4:59 pm
by richmond62
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)

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

Posted: Fri Apr 10, 2020 5:11 pm
by bogs
Heh, the correct answer was "Stop setting the group as a background, you dolt!"

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

Posted: Fri Apr 10, 2020 5:18 pm
by Klaus
Oh my, Richmond, you are a hopeless case! :D

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

Posted: Fri Apr 10, 2020 5:29 pm
by bogs
I think he is just adorable haha.

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

Posted: Fri Apr 10, 2020 5:38 pm
by richmond62
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)