Page 1 of 2
Can the void space within a group be made "Clickable"?
Posted: Wed Sep 02, 2020 4:01 am
by KimD
I've been playing around with mouse message handlers where the script is located on a group control. I've discovered that a message is only sent to the group script if I click on an actual object within the group. If I click on the void space, the empty area between the groups objects, then the group doesn't receive a mouseup, mousedown etc message.
Is there an easy way to make a group respond to mouse clicks that occur within the void space of the area it occupies? I realise that I could solve this by creating an object within the group, and always resizing that object to have the same size as the group. I was just wondering if there was another way of achieving the same
Set the respondToVoidMessages of group "XYZ" to true?
Thanks in advance
Kim
Re: Can the void space within a group be made "Clickable"?
Posted: Wed Sep 02, 2020 4:35 am
by kdjanz
Yes you can. Here is the group script for ordering a hamburger
Code: Select all
on mouseup
local tMenu
put "Cheese,Lettuce,Onion,Pickle,Tomato" into tMenu
if the label of the target is "Select All" then
repeat for each item tItem in tMenu
set the hilite of button tItem to true
end repeat
else if the label of the target is "Clear All" then
repeat for each item tItem in tMenu
set the hilite of button tItem to false
end repeat
else if the label of the target is "Place Order" then
visual effect "dissolve"
go to card "burger"
wait 3 seconds
visual effect "checkerboard"
go to card "main"
send "mouseUp" to button "ClearAll"
end if
if the label of the target is empty then put "In the background"
end mouseup
The image of the group is below
So the group itself has no label, so the final if catches the mouseUp in the empty space and puts a message into the message box.
Hope that helps
Kelly
Re: Can the void space within a group be made "Clickable"?
Posted: Wed Sep 02, 2020 5:00 am
by KimD
Thanks Kelly
I may not have explained this properly. The following answers "Hi" if I click on an object located within group "XYZ"
On MouseUp // Stored as a script of Group "XYZ"
Answer "Hi"
End MouseUp
But if I click on the empty space between two objects located within group "XYZ", then it doesn't answer of "Hi".
So the content of a mouseUp handler doesn't help me, as mouseUp never fires. It may come down to something specific about my scenario. I'm working on scrolling / zooming. Because of this what I have is graphics nested within a group within a group.
Card
+ Group "XYZ" // Which includes the mouseUp handler that's not working with clicks on empty space, and has its size and position locked
++ Group "ABC"
+++ Graphic "DEF"
+++ Graphic "HIJ"
+++ Graphic "KLM"
I can see how I could use your code to solve other problems, but not this problem

Re: Can the void space within a group be made "Clickable"?
Posted: Wed Sep 02, 2020 5:06 am
by Thierry
KimD wrote: ↑Wed Sep 02, 2020 4:01 am
I realise that I could solve this by creating an object within the group,
and always resizing that object to have the same size as the group.
Hi Kim,
AFAIK, this is the only way to do it...
till someone is coming with another solution
Regards,
Thierry
Re: Can the void space within a group be made "Clickable"?
Posted: Wed Sep 02, 2020 5:18 am
by KimD
Thanks Thierry. Yes - it would certainly be easy to do it by adding a group-sized object and layering it below everything else. I was just curious about whether LC might have a way of detecting clicks that occurred within the left/right/top/bottom bounds of a group, but not over an object of that group...
Re: Can the void space within a group be made "Clickable"?
Posted: Wed Sep 02, 2020 8:28 am
by richmond62
I am going to
avoid answering your question.
You may hate me for this suggestion . . .
Just
ungroup the group:
-
-
That's the image of your group on the right, and that's my re-creation of everything on the left
that is NOT grouped.
Re: Can the void space within a group be made "Clickable"?
Posted: Wed Sep 02, 2020 11:40 am
by Opaquer
I have this same issue in the app I'm working on at the moment. I've made identical handlers for the group and one for the card, then to check if the mouseUp on the card is within a certain area (such as the group rect or whatever)
Not sure how feasible that is for you, but for my situation, it's working so far. That said, if there's an even better way to do it, I would definitely be up for that!
Re: Can the void space within a group be made "Clickable"?
Posted: Wed Sep 02, 2020 11:50 am
by richmond62
If you want to check if your mouse is within a group use something like this:
Code: Select all
on mouseEnter
--do something
end mouseEnter
If you want to have a mouseUp statement in your cardscript and another mouseUp statement
in your groupScript this should NOT be necessary as, when you release your mouse button over the group
the mouseUp statement in the groupScript will fire and the one in the cardScript will not because
your group overlays the card.
Re: Can the void space within a group be made "Clickable"?
Posted: Wed Sep 02, 2020 1:03 pm
by Opaquer
The problem from what I can see is that the mouseEnter handler only works if you're doing stuff with objects in the actual group, right? If I click on an area within the group where there's no controls, the mouseEnter and mouseUp handler within the group itself don't fire, which is why I've got one for the card and one for the group, so that wherever the user clicks within the group, the event will be handled properly

Re: Can the void space within a group be made "Clickable"?
Posted: Wed Sep 02, 2020 1:55 pm
by dunbarx
Hi..
Just fool LC a little. 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
This is a kludge, for sure, but can easily be extended to any number of groups:
Code: Select all
on mouseUp
repeat with y = 1 to the number of grps
if the clickLoc is within the rect of grp y then
answer the name of grp y
exit repeat
end if
end repeat
end mouseUp
Craig
Re: Can the void space within a group be made "Clickable"?
Posted: Wed Sep 02, 2020 1:59 pm
by richmond62
IFF you want your group to pick up
mouseEnter,
mouseLeave,
mouseDown,
mouseStillDown and
mouseUp
signals make sure it is
opaque.
-
-
Re: Can the void space within a group be made "Clickable"?
Posted: Wed Sep 02, 2020 2:05 pm
by dunbarx
Richmond.
Your sample only acts on the controls within a group, no? Unless I am misusing it. The OP wants to know when a mouseUp message can be generated when clicking on the empty space in a group rect.
Overlaying a transparent graphic would do this, but then you have to kludge yet again to determine if the clickLoc was actually over a real control, which may also be of interest.
Craig
Re: Can the void space within a group be made "Clickable"?
Posted: Wed Sep 02, 2020 2:18 pm
by richmond62
If the group is
opaque mouse events are picked up where-ever you put your mouse.
Download my stack and have a go.

Re: Can the void space within a group be made "Clickable"?
Posted: Wed Sep 02, 2020 2:38 pm
by dunbarx
Richmond.
I did. Clicking in the empty space does nothing. I added a mouseUp handler to the group script. Nothing happens in the voids.
The handlers you do have only work when entering or leaving a control within the group. The point of the OP was to be able to use the empty space.
Where are we disconnected?
Craig
Re: Can the void space within a group be made "Clickable"?
Posted: Wed Sep 02, 2020 2:49 pm
by dunbarx
@KimD.
If you are following this thread, know that a group, though indeed a real control, does not quite have the solidity of, say, a button. It is defined in space by the extents of its child controls, but does not have any real substance apart from those controls. In other words, the empty space between controls in a group does not seem to be "part" of that group, in the sense that it has solidity.
I could be off base with the above, and would welcome comments from others, but if I am mainly correct, then only a kludge, as I posted above, will do what you want.
I am working with Richmond on his assertion that the opaque property solidifies the empty areas of the group, but I am not seeing what he is. That concept, however, on the face of it, seems like it ought to work, so watch this space.
Craig