Can the void space within a group be made "Clickable"?

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

KimD
Posts: 223
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

Can the void space within a group be made "Clickable"?

Post by KimD » Wed Sep 02, 2020 4:01 am

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

kdjanz
Posts: 300
Joined: Fri Dec 09, 2011 12:12 pm
Location: Fort Saskatchewan, AB Canada

Re: Can the void space within a group be made "Clickable"?

Post by kdjanz » Wed Sep 02, 2020 4:35 am

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 Image

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
Attachments
Group.png
Group.png (10.7 KiB) Viewed 6984 times

KimD
Posts: 223
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

Re: Can the void space within a group be made "Clickable"?

Post by KimD » Wed Sep 02, 2020 5:00 am

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 ;-)

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: Can the void space within a group be made "Clickable"?

Post by Thierry » Wed Sep 02, 2020 5:06 am

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
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

KimD
Posts: 223
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

Re: Can the void space within a group be made "Clickable"?

Post by KimD » Wed Sep 02, 2020 5:18 am

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...

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Can the void space within a group be made "Clickable"?

Post by richmond62 » Wed Sep 02, 2020 8:28 am

I am going to avoid answering your question.

You may hate me for this suggestion . . . 8)

Just ungroup the group:
-
Screenshot 2020-09-02 at 10.26.03.png
-
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.
Attachments
un-Click.livecode.zip
Here's the stack.
(12.75 KiB) Downloaded 161 times

Opaquer
Posts: 247
Joined: Wed Aug 14, 2013 8:24 am

Re: Can the void space within a group be made "Clickable"?

Post by Opaquer » Wed Sep 02, 2020 11:40 am

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!

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Can the void space within a group be made "Clickable"?

Post by richmond62 » Wed Sep 02, 2020 11:50 am

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.

Opaquer
Posts: 247
Joined: Wed Aug 14, 2013 8:24 am

Re: Can the void space within a group be made "Clickable"?

Post by Opaquer » Wed Sep 02, 2020 1:03 pm

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 :)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9669
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Can the void space within a group be made "Clickable"?

Post by dunbarx » Wed Sep 02, 2020 1:55 pm

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
Last edited by dunbarx on Wed Sep 02, 2020 2:00 pm, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Can the void space within a group be made "Clickable"?

Post by richmond62 » Wed Sep 02, 2020 1:59 pm

IFF you want your group to pick up mouseEnter, mouseLeave, mouseDown, mouseStillDown and mouseUp
signals make sure it is opaque.
-
Screenshot 2020-09-02 at 15.56.38.png
-
Screenshot 2020-09-02 at 15.58.35.png
Attachments
group click.livecode.zip
Here's the stack.
(1.05 KiB) Downloaded 176 times

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9669
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Can the void space within a group be made "Clickable"?

Post by dunbarx » Wed Sep 02, 2020 2:05 pm

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Can the void space within a group be made "Clickable"?

Post by richmond62 » Wed Sep 02, 2020 2:18 pm

If the group is opaque mouse events are picked up where-ever you put your mouse.

Download my stack and have a go. 8)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9669
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Can the void space within a group be made "Clickable"?

Post by dunbarx » Wed Sep 02, 2020 2:38 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9669
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Can the void space within a group be made "Clickable"?

Post by dunbarx » Wed Sep 02, 2020 2:49 pm

@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

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”