background and foreground

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

danielrr
Posts: 140
Joined: Mon Mar 04, 2013 4:03 pm

background and foreground

Post by danielrr » Sat Dec 23, 2023 9:00 pm

There was a programming environment for the Mac many years ago... well, surely no one remembers it, but the fact is that in this environment, which was also based on the concept of a stack, there was a basic opposition between background and card (foreground). This was very useful for applications such as the following: imagine a map on which we're going to develop a story (a kind of historical atlas) programming a series of events: the map would be in the background, and each card could be used to create different episodes that took place against that backdrop.

Naturally, LiveCode is an incomparably more developed environment, and many ways come to mind to do the same thing, but what is the most elegant and cost-effective way to use the same background shared by all the "cards" in a stack? Could you point me to a good example of a LiveCode stack where this is done?

Many thanks in advance.

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

Re: background and foreground

Post by richmond62 » Sat Dec 23, 2023 9:11 pm


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

Re: background and foreground

Post by richmond62 » Sat Dec 23, 2023 9:39 pm

Here's a very simple example I just made:
-
Screenshot 2023-12-23 at 22.18.44.jpg
Attachments
back image.livecode.zip
Stack.
(249.98 KiB) Downloaded 37 times

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

Re: background and foreground

Post by dunbarx » Sat Dec 23, 2023 11:27 pm

Hi.

Are you speaking of Hypercard?

The background implementation there is not the same as it is in LiveCode, where that concept is assigned to the behavior of groups. But since groups can be of any composition, like, as Richmond suggests, an image, that functionality can be easily (and better) implemented.

So whereas in HC one creates background buttons and fields, say, and these can be placed on any or all cards, and automatically when making a new card, in LC you use instead groups, and they have much the same behavior. Check out the "backGroundBehavior" in the dictionary.

It took me a long time to grudgingly admit that anything HC could do LC could do better. But that was obvious from the start; I just am ill-tempered.

Craig

stam
Posts: 2692
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: background and foreground

Post by stam » Sun Dec 24, 2023 1:03 am

danielrr wrote:
Sat Dec 23, 2023 9:00 pm
Naturally, LiveCode is an incomparably more developed environment, and many ways come to mind to do the same thing, but what is the most elegant and cost-effective way to use the same background shared by all the "cards" in a stack? Could you point me to a good example of a LiveCode stack where this is done?
LC is based on HyperCard, which it sounds like you're referring to. But it's not the same. Like Richmond and Craig have already said, "Background" is implemented but it's different.

In LC's case, "background" is an attribute of a group. In other words if you want a set a background that can be shared across cards, you create all the elements as you would do normally and group all the elements into a new group and in its property inspector set the 'background' to true.

For any new cards created from a card that has this background group, this will be included automatically but you can place the background on any card from the Object menu (-> place group). Conversely if you want remove the group from the card don't delete it, or it will delete all instances of the background from all card that have this - instead chose 'remove group' from the Object menu.

It also follows that you can have multiple premade backgrounds that you can pick and choose from for each card and that these are not mutually exclusive (for example I often have a background button/menubar for top of the screen and a different background group for the status bar at the bottom)

You can also use the resizeControl handler to reposition/resize elements of your background group so they will apply to any card/stack size, but that's a bit more advanced...

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

Re: background and foreground

Post by richmond62 » Sun Dec 24, 2023 12:42 pm

If you download my sample stack you will see it has 3 cards, all of which share the same background: the group consisting of only the photo of the deer.

I have given each card a different backGroundColor so, on button clicks, the seperate cards are easy to see.

Yes: odd as it may see, one can have a group that contains only one member. 8)

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

Re: background and foreground

Post by richmond62 » Sun Dec 24, 2023 12:48 pm

well, surely no one remembers it
Very, very hard to forget it: after BASIC, FORTRAN, PASCAL and ZILOG the Mac GUI and HyperCard were,
-
Used_Punchcard_(5151286161).jpg
-
quite literally, a mystical experience to me in 1993.
-
HCTour.jpg
-
Without HyperCard there might not be the type of web-browsers we now have, and there certainly would not be SuperCard, LiveCode, or OpenXTalk.

However, just as most Americans, Canadians, Australians, New Zealanders, English and Scots people (OK, OK: and the Welsh and the Irish) do most definitely not speak Shakespearean English (God, Wot, quoth he in a moment of mirth), so SuperCard, LiveCode, and OpenXTalk do not 'speak' HyperTalk (the programming language inwith HyperCard), they speak modern dialects of HyperTalk, with, in addition to some lexical and semantic changes, increased lexica.

danielrr
Posts: 140
Joined: Mon Mar 04, 2013 4:03 pm

Re: background and foreground

Post by danielrr » Sun Dec 24, 2023 1:19 pm

richmond62 wrote:
Sat Dec 23, 2023 9:39 pm
Here's a very simple example I just made:
-
Screenshot 2023-12-23 at 22.18.44.jpg
Just perfect, thanks!

danielrr
Posts: 140
Joined: Mon Mar 04, 2013 4:03 pm

Re: background and foreground

Post by danielrr » Sun Dec 24, 2023 1:21 pm

stam wrote:
Sun Dec 24, 2023 1:03 am
danielrr wrote:
Sat Dec 23, 2023 9:00 pm
Naturally, LiveCode is an incomparably more developed environment, and many ways come to mind to do the same thing, but what is the most elegant and cost-effective way to use the same background shared by all the "cards" in a stack? Could you point me to a good example of a LiveCode stack where this is done?
LC is based on HyperCard, which it sounds like you're referring to. But it's not the same. Like Richmond and Craig have already said, "Background" is implemented but it's different.

In LC's case, "background" is an attribute of a group. In other words if you want a set a background that can be shared across cards, you create all the elements as you would do normally and group all the elements into a new group and in its property inspector set the 'background' to true.

For any new cards created from a card that has this background group, this will be included automatically but you can place the background on any card from the Object menu (-> place group). Conversely if you want remove the group from the card don't delete it, or it will delete all instances of the background from all card that have this - instead chose 'remove group' from the Object menu.

It also follows that you can have multiple premade backgrounds that you can pick and choose from for each card and that these are not mutually exclusive (for example I often have a background button/menubar for top of the screen and a different background group for the status bar at the bottom)

You can also use the resizeControl handler to reposition/resize elements of your background group so they will apply to any card/stack size, but that's a bit more advanced...
Thanks again to DumbarX (by the nth time) and Stem by their clear clarification of concepts I hadn't fully grasped yet

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

Re: background and foreground

Post by richmond62 » Sun Dec 24, 2023 1:29 pm

DumbarX (by the nth time) and Stem
Who are they?

Funnily enough, most people spell my name wrongly and get those 2 right. 8)

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

Re: background and foreground

Post by dunbarx » Sun Dec 24, 2023 5:09 pm

Richard.

He said "Stem". Possibly autoCorrect, but is that any excuse?

Dumbarx

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

Re: background and foreground

Post by richmond62 » Sun Dec 24, 2023 5:39 pm

Dear DumbarX and Stem, I wish you all the best this Christmas.

Your's aye, Richard.

danielrr
Posts: 140
Joined: Mon Mar 04, 2013 4:03 pm

Re: background and foreground

Post by danielrr » Sun Dec 24, 2023 6:27 pm

richmond62 wrote:
Sun Dec 24, 2023 5:39 pm
Dear DumbarX and Stem, I wish you all the best this Christmas.

Your's aye, Richard.
I meant Stam. Don't be tough on me this time of the year Richmond :D

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

Re: background and foreground

Post by jacque » Sun Dec 24, 2023 7:30 pm

DumbarX and Stem
I LOVE this. Sounds like a comedy team. They should go on the road. 🤣
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

stam
Posts: 2692
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: background and foreground

Post by stam » Sun Dec 24, 2023 7:35 pm

Trust me, with a Greek name like mine I’ve been called worse ;)

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”