Toto... I have a feeling we're not in HyperCard anymore (backgrounds & groups)

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

mluka
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 73
Joined: Sun Jun 17, 2007 12:08 am

Toto... I have a feeling we're not in HyperCard anymore (backgrounds & groups)

Post by mluka » Thu Nov 23, 2017 12:18 am

Hi all.

Kind of confused, using LC 8.1.8.

In the old days, I could "Edit background". HC would then put a special border around the window and then I could put whatever I wanted in this background and it would appear on every card of this background.

I could also refer to the background and move cards, insert cards, etc. I could "Go to the first card of bg XYZ", for instance.

Now, with LC, we have groups (but in the documentation, "group" seems to be almost synonymous with "background"). If I understand the concept of groups, it means "some controls that have been grouped together, that may sometimes appear automatically on new cards and that may, optionally, act as a background". Pheeew!
-------------------------
Suppose I want to have these characteristics, among others, in a stack:
  1. Every card has a label and field that display the card's number and its short name (for troubleshooting during development). I've grouped the label and field. Is this a background???
  2. Two cards ("About" and "Tech documentation") are the first two cards of the stack.
  3. Every card has basic navigation buttons (say: Prev, Next and Home). Really, these should be grouped together, to keep the same location, spacing, etc. Is this also a background?
  4. There would be two "groups of cards", say "Classical" and "Jazz". Each "group" would have one "Index" card, listing the name of each card of this "group", and several individual cards. The layout (fields, buttons, etc.) for both "groups" would be identical. But I want to add new cards, say, to a specific group. And I want the Index card of each "group" to list the cards of this "group" only, not all the cards in the stack. If these cards (except for the Index cards) have the same layout, and the same controls, how do I "group" them separately??? There must be a way for me to refer to "the Index card of bg Classical" and "the Index card of bg Jazz"...
Can someone kindly point me in the right direction here? Maybe there's a tutorial that explains all this?

(My friend Daniel says that I tend to over-complicate things sometimes... Is this one of those cases???

Thanks!
Michel
Montréal, Canada

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

Re: Toto... I have a feeling we're not in HyperCard anymore (backgrounds & groups)

Post by bogs » Thu Nov 23, 2017 1:10 am

mluka wrote:
Thu Nov 23, 2017 12:18 am
In the old days, I could "Edit background". HC would then put a special border around the window and then I could put whatever I wanted in this background and it would appear on every card of this background.
....
If I understand the concept of groups, it means "some controls that have been grouped together, that may sometimes appear automatically on new cards and that may, optionally, act as a background".
In the case of a group, "some controls" actually means any number of controls from 1 -> up. When you check 'shared' and 'behave like background' in the property inspector for a group, it is indeed like ye olden days, it is a background that is "editable", can appear on every card (or be removed from specific ones while not affecting the rest), etc.
I could also refer to the background and move cards, insert cards, etc. I could "Go to the first card of bg XYZ", for instance.
This still works the same, far as I can determine, but you can't place a card in a group I think...(correction?)
Suppose I want to have these characteristics, among others, in a stack:
1. Yes, if you want the cards number and short name displayed in those objects, you would do it through code, most likely in the 'openCard' event, i.e.

Code: Select all

on openCard 
    put the short name of this card into field "grpField"
    put the number of this card into label "crdNum"
end openCard
2. Yup.
3. Yup.
4. You put one group layout into one group, say group "Classical", and the other into another group say group "Jazz". I would think a fairly simple if/then or switch/case would be able to handle spreading the group to the proper cards.

For a fairly good intro, try here or here.
(My friend Daniel says that I tend to over-complicate things sometimes... Is this one of those cases???
Only if you start over-complicating it... :wink:
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Toto... I have a feeling we're not in HyperCard anymore (backgrounds & groups)

Post by jacque » Fri Nov 24, 2017 5:31 am

A group with backgroundbehavior set to true will behave like a HC background. It will be used on new cards and receive messages after the card gets them.

A group without backgroundbehavior is a card group. It receives messages before the card gets them and is not shown on new cards (unless the card has been cloned from one with card groups.)

Card groups can be optionally shared on other cards. Background groups are always shared.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10327
Joined: Wed May 06, 2009 2:28 pm

Re: Toto... I have a feeling we're not in HyperCard anymore (backgrounds & groups)

Post by dunbarx » Sat Nov 25, 2017 1:36 am

Functionally, a group with bg behavior set will act like a HC bg. But it is not one, and may not always look like one.

If you make a bg group that occupies the entire extent of the card, you might think that LC and HC were built the same. But in HC, the bg is its own card-sized object class, and always is a full-sized "layer" upon which cards can exist. The bg owns the cards that nest on it. It is not a control that can be moved around the screen. It always lies in the message hierarchy between cards and the engine.

In LC, a bg group really is just a collection of controls that possess bg functionality. In one sense, that makes them more flexible. In another sense, we have lost a fundamental native "layer" in the message hierarchy.

I wish we had both.

Craig Newman
Last edited by dunbarx on Sat Nov 25, 2017 4:21 am, edited 1 time in total.

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

Re: Toto... I have a feeling we're not in HyperCard anymore (backgrounds & groups)

Post by bogs » Sat Nov 25, 2017 3:23 am

jacque wrote:
Fri Nov 24, 2017 5:31 am
Card groups can be optionally shared on other cards. Background groups are always shared.
Ah, I think I just saw a basic flaw in my understanding the question asked. I thought he actually meant grouping a number of cards, but the way I'm reading this is grouping controls on a card = card group. If thats so, I feel like such a nozzle :oops:
I wish we had both.
Sounds like it would be neat to have it both ways, Craig.
Image

mluka
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 73
Joined: Sun Jun 17, 2007 12:08 am

Re: Toto... I have a feeling we're not in HyperCard anymore (backgrounds & groups)

Post by mluka » Sat Nov 25, 2017 8:02 pm

Hi. Thanks for all the responses!
bogs said: I thought he actually meant grouping a number of cards, but the way I'm reading this is grouping controls on a card = card group.
Hey! Don't feel bad: the "old" bg way of thinking made it (in my head anyway) very clear where cards fit: if you had several backgrounds in a stack, each card was in this background or that background, etc.

I understand that the LC groups achieve the same result. But, conceptually, in my head, it's more complicated. In LC, you can have a group inside another group. Can then each group be referred to as a background???

Which may just be a question of semantics.

Anyway, thanks for the comments and suggestions: I will go through the suggested references.
Michel
Montréal, Canada

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

Re: Toto... I have a feeling we're not in HyperCard anymore (backgrounds & groups)

Post by bogs » Sat Nov 25, 2017 9:02 pm

mluka wrote:
Sat Nov 25, 2017 8:02 pm
I understand that the LC groups achieve the same result. But, conceptually, in my head, it's more complicated. In LC, you can have a group inside another group. Can then each group be referred to as a background???
To be set as a bg, it has to be the top level group. If other groups are inside of the top level group, and the top level group is a 'background', the other groups would be like controls inside the background, however they could not be set to 'background'. Well, you could set it, but it would have no effect or throw an error.
Dictionary wrote: Comments:
Only top-level groups may be background groups; an attempt to set the backgroundBehavior of a nested group to true throws an error.
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10327
Joined: Wed May 06, 2009 2:28 pm

Re: Toto... I have a feeling we're not in HyperCard anymore (backgrounds & groups)

Post by dunbarx » Sun Nov 26, 2017 4:47 pm

The differences are fundamental. LC changed the paradigm.

As Bogs mentioned, in HC, you can have two backGrounds in a stack. The first one can contain ten cards. The second one can contain ten different cards. You could sort the cards of bg 1 in one line of code. You could have entirely different control suites on each of the two bgs. You could do much more...

The HC bg was its own object class. I like the LC group. I miss the HC bg.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Toto... I have a feeling we're not in HyperCard anymore (backgrounds & groups)

Post by FourthWorld » Sun Nov 26, 2017 5:42 pm

dunbarx wrote:
Sun Nov 26, 2017 4:47 pm
The HC bg was its own object class. I like the LC group. I miss the HC bg.
LC's groups are a superset of HyperCard's background features. What would you like do to in LC that could be done with HC bgs?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10327
Joined: Wed May 06, 2009 2:28 pm

Re: Toto... I have a feeling we're not in HyperCard anymore (backgrounds & groups)

Post by dunbarx » Sun Nov 26, 2017 9:04 pm

Richard.

Sort cards of bg "ninthBackground" by fld 2 of each.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Toto... I have a feeling we're not in HyperCard anymore (backgrounds & groups)

Post by FourthWorld » Mon Nov 27, 2017 3:00 am

dunbarx wrote:
Sun Nov 26, 2017 9:04 pm
Sort cards of bg "ninthBackground" by fld 2 of each.
Interesting. I haven't stored data in UI objects in a long time so I haven't had occasion to see that.

I know that the sort command works on cards, and that cards can be sorted by field contents. So is the limitation that LC doesn't also allow a qualifier of restricting the sort to a specified background?

Is that a bug?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10327
Joined: Wed May 06, 2009 2:28 pm

Re: Toto... I have a feeling we're not in HyperCard anymore (backgrounds & groups)

Post by dunbarx » Mon Nov 27, 2017 3:07 pm

Richard.

I don't think it is a bug, just a consequence of losing the HC-style bg.
I haven't stored data in UI objects in a long time so I haven't had occasion to see that.
I could have used any other sortKey. The point is that HC backGrounds had their own place. The fact that each one owned its own cards perhaps being the most useful.

Groups in LC have their own power and functionality, but they cannot take the place of what is essentially an entirely different object type, that had its own features and attributes. The only really similar thing between them is that they both lie above (Jacque :wink: ) cards in the hierarchy. HC bg's because they are just higher, and LC groups because, well, just because.

This is just the way things are. There are always workarounds...

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Toto... I have a feeling we're not in HyperCard anymore (backgrounds & groups)

Post by FourthWorld » Mon Nov 27, 2017 5:29 pm

True, LiveCode's groups are far more flexible than HC's backgrounds, and for the wide range of uses they serve having their scripts on the same visual layering order as other controls generally works well, though it is different from HC.

But back in the day I ported a lot of HC stacks, and aside from things like calls to HC's ColorIt external most of the scripts worked well after import.

When importing a HC stack, you wind up with one group below all card controls, sized the to fit the card, with its backgroundBehavior set to true. If you create a new stack with a group that conforms to those constraints you should get a similar result.

That last part, the backgroundBehavior, is key to mimicking HC's backgrounds. Indeed, it was added specifically for that purpose.

False by default, it's a group, with its script occupying a place in the message path similar to any other control.

But when the backgroundBehavior is set to true, it effectively becomes a background: its script will then occupy the same place in the message path as with HC, between the card and stack scripts.

If you tested the sort syntax without first setting the group's backgroundBehavior, set that and try it again.

If it still doesn't work consider filing either a bug report or an enhancement request. Given how seldom we mix UI and persistent storage these days I can't guarantee it'll be a high priority, and even HyperCard compatibility is a tough sell these days, given that it's been nearly two decades since Apple pulled the plug on HC and any stacks that were worth porting were likely already ported long ago.

But if nothing else it would be interesting to learn if the bg qualifier for the "sort cards" command was originally intended to be supported.

I did a lot of HC ports around the turn of the century, in a lot of different xTalks (SuperCard, Gain Momentum, Spinnaker Plus, OMO, ToolBook) and LC offered a smoother import process and better script compatibility than any of them.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Toto... I have a feeling we're not in HyperCard anymore (backgrounds & groups)

Post by jacque » Mon Nov 27, 2017 6:18 pm

It's not a bug, sorting by background has never been available. As far as I know it's the only difference in background behavior between LC and HC. MetaCard didn't have it either.

I used that feature so rarely that I never missed it when it was gone, and after I stopped using stacks as databases I didn't need it anyway.

I'm pretty sure the behavior could be scripted though if someone really needed it.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10327
Joined: Wed May 06, 2009 2:28 pm

Re: Toto... I have a feeling we're not in HyperCard anymore (backgrounds & groups)

Post by dunbarx » Mon Nov 27, 2017 8:52 pm

Jacque.
I used that feature so rarely that I never missed it when it was gone, and after I stopped using stacks as databases I didn't need it anyway.
I did it quite often, always having my databases in the stack.

But you made an intriguing claim. The only way I can see simulating the HC sort-by-background would be to:

Code: Select all

remember the current card order
set a custom property of the cards of interest and mark them
note the position of the first marked cd
sort marked cds by using the custom prop as a sortKey
set the marked cd order so that the first one takes the number of the original marked cd
This sort of works, because it messes up the original order of the unmarked cards. I suppose one could work around that as well with a bit more fooling around. And without marked cds, another holdout from the past, I bet, that is also likely little used (I have never seen a forum post on it) the task becomes more tedious.

Anyway, nobody seems to care much, even the old HC'ers. Oh well...

Craig

Post Reply