Groups an attempt at understanding.

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Groups an attempt at understanding.

Post by Simon Knight » Mon May 27, 2019 3:00 pm

In a recent post I mentioned that I struggled to understand how some of the more advanced features of a LC group worked. So in an attempt to gain some insight I have created a stack that allows some properties of a simple group to be toggled on and off. The group comprises eight LC graphic objects with the option of adding and deleting a ninth.

The interaction between the rect of the group and the boundingRect of the group is worth experimenting with, it seems that setting are only applied when an object is added or deleted (and probably moved but I have not tried this). Confusion may occur if the scroll bars are scrolled when the boundingRect is set. Well it confuses me!

I am attaching my test stack as someone else may find it useful, however I make no claims for accuracy or correctness, so buyer beware.

I have two questions which I hope someone will answer:

1) Why does deleting an object from a group requires the use of a odd construct (see button add control ); the code line

Code: Select all

delete graphic "OneExtra" of group "viewergroup"
fails and throws an error when called from the mouseup handler. It requires that the mouseup handler finishes before the delete will work. This is achieved by putting the line in its own handler and using a send message from the mouseup.

Code: Select all

On mouseUp
Send "DeleteLast" to me in 0 seconds
end mouseUp
On DeleteLast
   delete graphic "OneExtra" of group "viewergroup"
   UpdateSizeAndLocationFields
end DeleteLast
Why is this needed and where else is it needed?

2) The object inspector of a group includes a boolean property named "resize". This may be toggled on or off but does not seem to do anything. I have not found a dictionary entry. I have not been able to set the value using code either in a handler or from the message box. Lastly the message box will only read the value once: what I mean is that the line

Code: Select all

put the resize of group "my group"
will return either true or false when first called depending on what has been set in the property inspector. However, when the value is changed in the inspector the change is not returned by the line in the message box.

I apologise in advance for any "Schoolboy errors" that I have made.

best wishes
Simon
Attachments
GroupsExperiment.livecode 2.zip
(14.55 KiB) Downloaded 184 times
best wishes
Skids

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Groups an attempt at understanding.

Post by jacque » Tue May 28, 2019 5:26 pm

First question, you can't delete an object while its script is running. You could, in this case, use the simpler command if it was issued from a different script.

Second question, I assume you mean the resize checkbox in the Size and Location pane of the inspector? As far as I know, that's just a custom property of the inspector that controls how the object rectangle will change. If false, changing the location of one of the sides will move the object to accommodate. If true, changing a side will rescale the rectangle so only that side's location changes and the other three sides remain in place.

I.e., if resize is false, setting the left to 50 pixels will move the whole object so that the left is at 50. If true, the other 3 sides will not change but the left will be set to 50 which will make the object either wider or thinner.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Groups an attempt at understanding.

Post by Klaus » Tue May 28, 2019 6:36 pm

Hi Simon,

I created a button with this script:

Code: Select all

on mouseUp
   delete grc "Rectangle1" of grp "viewergroup"
end mouseUp
Worked as advertized.

I changed the script of your btn "Add Control" to:

Code: Select all

on mouseUp
   delete graphic "Rectangle 2" of group "viewergroup"
   exit mouseup
  ...
end mouseup
Which also worked as advertized!?
As Jaques wrote, you cannot delete a control which script is currently running, but this is not the case here. So everything is working as it should!

RESIZE
Jaques is right again, this is a custom property used by the IDE.
You can differ custom props from build-in props (like height etc) by looking at the script.
The latter ones are always COLORIZED in the editor! 8)

Best

Klaus

Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Groups an attempt at understanding.

Post by Simon Knight » Wed May 29, 2019 8:54 am

Thank you both for your clear explanations and experimentation.

Delete Group:
I can now confirm that the delete group line of code works without the complication of using the send command. However, at the time of writing my first post it failed. I guess that the IDE was in an odd state at the time.

Resize Checkbox:
Yes I meant the checkbox in the object size and location tab of the inspector, I apologise for not being clear:
Screen Shot 2019-05-29 at 08.26.50.png
Screen Shot 2019-05-29 at 08.26.50.png (34.13 KiB) Viewed 2582 times
Thanks to your explanations I now understand how it operates. I think that it is unfortunate that RunRev use a checkbox for this IDE function as its bound to cause confusion. For example the two other checkboxes on the pane refer to properties of the selected object rather than a function of the IDE and the documentation is of little help :
The Property Inspector allows you to view and edit the properties for any selected object.
and
Important: For documentation on what each individual object property does, hover the mouse over the object until you see the script property equivalent. Then look that term up in the LiveCode Dictionary.
Screen Shot 2019-05-29 at 08.45.51.png
When is a property not a property? When its not in the dictionary. Ouch!

best wishes
Simon
best wishes
Skids

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

Re: Groups an attempt at understanding.

Post by bogs » Wed May 29, 2019 9:35 am

Simon Knight wrote:
Wed May 29, 2019 8:54 am
I think that it is unfortunate that RunRev use a checkbox for this IDE function as its bound to cause confusion.
Well, I suppose it *could* cause confusion, as you are the example here, and you were confused by it :wink:

However, you had also discovered that this was a boolean toggle all on your own (cleverly as well), and it is sitting distinctly with a group of coordinates describing an object. How you did enough experimentation to figure out it is boolean and toggles, but then don't (apparently) change any setting below it when toggling on/off to see the effect it might have is confusing in and of itself, at least to me :D

Of course, you also had some luck element involved as well, as a group object, which is probably the worst possible object to try and see anything happen with the 'resize' toggled since it is largely invisible in its default state was the object you were playing with at the time. Had it been a button, field, or almost anything else, I'm pretty sure you would have figured it out immediately :twisted:

The last thing I would add is this, really, where else would you put it? It is literally there to toggle whether the left, top, right, and bottom integers 'move' the rect around, or 'resize' it. I do wish they had left the graphic in that actually gave you a preview as to what was happening, though.
Selection_001.png
Resize me baby!
Image

Post Reply

Return to “Talking LiveCode”