how to make a whole group into a target
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
- Posts: 508
- Joined: Sun Dec 18, 2011 7:23 pm
- Location: London
- Contact:
how to make a whole group into a target
I have a group with several different controls. I want to make the whole rectangle into a target, so clicking anywhere will send a message to the group. I can't find a way of doing that except to put a button as a backdrop. But that has other complications.
Any way of ensuring the whole area of a group is clickable?
Any way of ensuring the whole area of a group is clickable?
Kaveh
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: how to make a whole group into a target
Hi.
I suspect there is a more straightForward way to do what you want, but you can always use native LiveCode behavior. In the card script:
Craig Newman
I suspect there is a more straightForward way to do what you want, but you can always use native LiveCode behavior. In the card script:
Code: Select all
on mouseUp
if the clickLoc is within the rect of grp "yourRecalcitrantGroup" then answer random(99)
end mouseUp
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
- Contact:
Re: how to make a whole group into a target
@Kaveh - A group won't receive mouse event messages. You would need to add a transparent button or graphic in order for clicks to to send message like mouseUp. While not ideal, this approach does allow you to put your mouseUp/mouseDown/whatever message in the group script.
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
-
- Livecode Opensource Backer
- Posts: 508
- Joined: Sun Dec 18, 2011 7:23 pm
- Location: London
- Contact:
Re: how to make a whole group into a target
Thanks Craig and Trevor
I ended up putting a transparent button behind the other controls. That way mouse messages can be sent directly to each control in the field, but then trapped by the back button if not caught by others.
What would the advantage be to having the transparent button in front?
I ended up putting a transparent button behind the other controls. That way mouse messages can be sent directly to each control in the field, but then trapped by the back button if not caught by others.
What would the advantage be to having the transparent button in front?
Kaveh
-
- Livecode Opensource Backer
- Posts: 508
- Joined: Sun Dec 18, 2011 7:23 pm
- Location: London
- Contact:
Re: how to make a whole group into a target
Ah, I should read posts more carefully. I thought Trevor was suggesting a button on top. My error and my confusion. Thanks all.
Kaveh
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: how to make a whole group into a target
Many ways to do this. Know that if you move the group you also have to move the button, unless you have placed that button within the group itself. It was not clear to me that you had done so.
There was a thread a while back wondering if the empty space within the rect of a group might be allowed to react to a mouse click. This is exactly what you are talking about here.
Craig
There was a thread a while back wondering if the empty space within the rect of a group might be allowed to react to a mouse click. This is exactly what you are talking about here.
Craig
-
- Livecode Opensource Backer
- Posts: 508
- Joined: Sun Dec 18, 2011 7:23 pm
- Location: London
- Contact:
Re: how to make a whole group into a target
Hi Craig
Indeed I put the button inside the group. I am hiding and showing different elements of the group so the size changes. I have put several sizes in the custom properties of the button, so just call those as needed. Looking ok.
I think an option to have a "backdrop" to a group would make logical sense.
Regards
Kaveh
Indeed I put the button inside the group. I am hiding and showing different elements of the group so the size changes. I have put several sizes in the custom properties of the button, so just call those as needed. Looking ok.
I think an option to have a "backdrop" to a group would make logical sense.
Regards
Kaveh
Kaveh
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: how to make a whole group into a target
What Klaus said.What would the advantage be to having the transparent button in front?
The kluge to fix that, since such a button would indeed intercept all messages, would be to:
Code: Select all
on mouseUp
send "mouseUp" to grp "yourUnderLyingGroup"
Do you like that way better than the card script handler I proposed? I only ask because they are both kluges. In one, the card reacts to a mouse click, and checks the rect of the group, and in the other, the button reacts; they both, you might say, underlie the group, and trap those messages that pass right through.
I think a group, which is natively invisible (apart from its child controls), ought to be able to be merely transparent.
Craig
-
- Livecode Opensource Backer
- Posts: 508
- Joined: Sun Dec 18, 2011 7:23 pm
- Location: London
- Contact:
Re: how to make a whole group into a target
Hi Craig. It's great there are so many ways to fix things in LiveCode. I do like your method. For the moment the "backdrop" seems to be working ok...
Kaveh
Re: how to make a whole group into a target
I don't know if it has to do exactly with this topic but:
In an app I'm making to create calendars I have a group containing 42 boxes (graphic objects). In the script of the group:
on mouseup
answer me & cr & the target
end mouseup
---
The result when clicking anywhere in the group is:
group "esp_b01GrupoParri"
graphic "cas_b01f24"
The name of the graphic depends on which box I have clicked on.
In an app I'm making to create calendars I have a group containing 42 boxes (graphic objects). In the script of the group:
on mouseup
answer me & cr & the target
end mouseup
---
The result when clicking anywhere in the group is:
group "esp_b01GrupoParri"
graphic "cas_b01f24"
The name of the graphic depends on which box I have clicked on.
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: how to make a whole group into a target
Hi.
Not exactly sure what the question is, but when you ask for "me" you are asking for the contents of a control, This could be the text of a field, or even a button. But a graphic is not a container, and you will not get much asking for what it, er, contains.
With that line of code, when you click on a graphic, you will get its owner and its name. If the graphic was not owned by a group, you would get the card and its name.
So the question is this: what do you really want LC to send back to you when you click on a graphic?
Craig
Not exactly sure what the question is, but when you ask for "me" you are asking for the contents of a control, This could be the text of a field, or even a button. But a graphic is not a container, and you will not get much asking for what it, er, contains.
With that line of code, when you click on a graphic, you will get its owner and its name. If the graphic was not owned by a group, you would get the card and its name.
So the question is this: what do you really want LC to send back to you when you click on a graphic?
Craig
Re: how to make a whole group into a target
Well, it wasn't really a question. What happened is that I had read above:
and I only meant to comment that, in my experience, a group can receive messages... But I guess the subject of the post is a bit more complex and I didn't quite understand it. Anyway thanks, Craig, for your explanation.
A group won't receive mouse event messages. You would need to add a transparent button, etc...
and I only meant to comment that, in my experience, a group can receive messages... But I guess the subject of the post is a bit more complex and I didn't quite understand it. Anyway thanks, Craig, for your explanation.
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: how to make a whole group into a target
OK, I see.
It is important to know, I guess, that a group is only a group on paper; it is not an object in its own right. That is, empty space in a group is just that, empty space.
This is slightly odd because a group has an "opaque" property, and you can color that empty space as you like. But any colored empty area still does not quite seem to exist.
But even a load of empty space still has a rect. So I still think that the idea of checking to see if the clickLoc is within that rect is a nice kludge.
Craig
It is important to know, I guess, that a group is only a group on paper; it is not an object in its own right. That is, empty space in a group is just that, empty space.
This is slightly odd because a group has an "opaque" property, and you can color that empty space as you like. But any colored empty area still does not quite seem to exist.
But even a load of empty space still has a rect. So I still think that the idea of checking to see if the clickLoc is within that rect is a nice kludge.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 7229
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: how to make a whole group into a target
Almost. "Me " refers to the control whose script is referring to "me". It doesn't deal with the contents of that control, just its identity.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com