Buttons and backgrounds

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Judson
Posts: 26
Joined: Fri May 07, 2010 9:15 pm

Re: Buttons and backgrounds

Post by Judson » Sun Aug 01, 2010 5:15 am

I do appreciate the help. Your extracts are in bf:

Editing groups and copying and pasting cards are not related. In Revolution, groups contain only controls, not cards.

A group is a collection of buttons and fields templates but no content. Yes?

Groups can be placed on cards, but you can't place cards in groups.

I accept this.

If you want to add some controls to a group, select and copy the controls (not the card) and then edit a group to paste them in.

I think you have successfully shown me how to do that. And I appreciate your clarity in that matter.

If you want to add a card with a group,

By this I believe you are saying, if you want to add a card such that the card carries with it one (or more?) groups...

you could duplicate the card

by this you mean "clone this card"?

or simply create a new card, but either way you need background behavior enabled for your group beforehand.

Both clone and new create new cards with the group aka background of the previous card. In clone the new card contains the same content and in new it is empty.

The backgroundbehavior is true, so this is consistent with how you describe it to be.



If you want to copy cards elsewhere and modify them some, just copy and paste the card; don't do any of the group-editing procedures.

This is exactly what I am attempting to do and what is not working.


I'm not sure which of these you are trying to accomplish now. First get these concepts firm, then you'll be able to follow the instructions from myself and Mark and choose the best methods to pursue. (If you get stuck, I can help you clean up your stack if you follow the link below to my contact information!)[/quote]

Options are very much appreciated.

Curry
Posts: 111
Joined: Mon Oct 15, 2007 11:34 pm
Location: USA
Contact:

Re: Buttons and backgrounds

Post by Curry » Sun Aug 01, 2010 5:36 am

You'll get the hang of it!

A group is a collection of controls. Fields in groups can either have the same content or different content per card depending on the sharedText setting. Buttons have a similar mechanism.

For copying cards: copy card, navigate to another card where you want to insert, then paste. (No editing groups.)

Or clone a card and then set the card's number to put it where you want in relation to other cards.
Best wishes,

Curry Kenworthy

LiveCode Development, Training & Consulting
http://livecodeconsulting.com/

WordLib: Conquer MS Word & OpenOffice
SpreadLib: "Excel-lent" spreadsheet import/export
http://livecodeaddons.com/

Judson
Posts: 26
Joined: Fri May 07, 2010 9:15 pm

Re: Buttons and backgrounds

Post by Judson » Sun Aug 01, 2010 5:55 am

For copying cards: copy card, navigate to another card where you want to insert, then paste. (No editing groups.)

This does not work as advertised. A card resembling the copied card is pasted but it has a new group that is unique to this card. I need it to have the same group as the card copied.

Or clone a card and then set the card's number to put it where you want in relation to other cards.

At first glance this does appear to be a way around the problem. I will have to test more to see that it inserts correctly and doesn't clobber anything.

Curry
Posts: 111
Joined: Mon Oct 15, 2007 11:34 pm
Location: USA
Contact:

Re: Buttons and backgrounds

Post by Curry » Sun Aug 01, 2010 6:20 am

This does not work as advertised. A card resembling the copied card is pasted but it has a new group that is unique to this card.
That's what I get too! Good observation. Better use clone, then.
Best wishes,

Curry Kenworthy

LiveCode Development, Training & Consulting
http://livecodeconsulting.com/

WordLib: Conquer MS Word & OpenOffice
SpreadLib: "Excel-lent" spreadsheet import/export
http://livecodeaddons.com/

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Buttons and backgrounds

Post by Mark » Sun Aug 01, 2010 11:46 am

Hi Judson (and Curry),

You might as well group all objects (including existing groups) on a card, create a new cards and "place" the group. This might be slightly easier to understand, as no scripting is necessary for this.

I read a question somewhere earlier in this thread, about contents of objects. When you copy a group, contents is usually preserved. An exception to this rule is fields, which have unique content on each card if their sharedText property is set to false.

Best regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Curry
Posts: 111
Joined: Mon Oct 15, 2007 11:34 pm
Location: USA
Contact:

Re: Buttons and backgrounds

Post by Curry » Sun Aug 01, 2010 9:16 pm

Thanks, Mark. However, I believe he wanted to start with similar content but make slight modifications each time.

For anyone moving from HC: with Rev it's also possible to use only one card per interface design and store your data in an array or property (or database) rather than having thousands of cards with a background. On the other hand, it's good to have choices, so if you feel comfortable with the many-cards approach, you certainly can use that method!
Best wishes,

Curry Kenworthy

LiveCode Development, Training & Consulting
http://livecodeconsulting.com/

WordLib: Conquer MS Word & OpenOffice
SpreadLib: "Excel-lent" spreadsheet import/export
http://livecodeaddons.com/

Judson
Posts: 26
Joined: Fri May 07, 2010 9:15 pm

Re: Buttons and backgrounds

Post by Judson » Mon Aug 02, 2010 7:16 pm

Mark and Curry,

Yes, I understand that a database approach (rather than a card approach) has merit. But right now I need to port 40,000 cards in two stacks and another dozen stacks of code and get that working so I can maintain a production line.

And yes, I want to start with similar content and make slight modifications each time.

So far the only solution devised for an old-fashioned "copy card paste card" is the hack Curry suggested such is a "clone this card" followed by figuring out what card number I want to move the card to, and then changing the card number. This does work and it can probably be functionalized.

Thank you both and if anybody has any ideas that would be appreciated. Copy card paste card. This should not be rocket science.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Buttons and backgrounds

Post by Mark » Mon Aug 02, 2010 10:46 pm

Hi Curry and Judson,

Let me finish my contributions to this thread with the remark that RunRev can become extremely sluggish if you have tens of thousands of cards, particularly if each card contains its own unique controls. Editing groups, using the find command and building standalones may become really cumbersome.

Best regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Curry
Posts: 111
Joined: Mon Oct 15, 2007 11:34 pm
Location: USA
Contact:

Re: Buttons and backgrounds

Post by Curry » Tue Aug 03, 2010 4:49 am

RunRev can become extremely sluggish if you have tens of thousands of cards
Yep, I bet that's the issue on the other speed-related thread! Cheers.
Best wishes,

Curry Kenworthy

LiveCode Development, Training & Consulting
http://livecodeconsulting.com/

WordLib: Conquer MS Word & OpenOffice
SpreadLib: "Excel-lent" spreadsheet import/export
http://livecodeaddons.com/

Judson
Posts: 26
Joined: Fri May 07, 2010 9:15 pm

Re: Buttons and backgrounds

Post by Judson » Tue Aug 10, 2010 4:08 am

Mark and Curry,

Thank you both for your help here in defining how to cut or copy and paste cards.

In case anyone ever needs them here are three functions that do the trick. For the moment they are each a button function and part of the main stack group but once I get around to fixing up menus I can put them on a menu. The only thing different between a normal cut or copy and paste is that there is no clipboard and ergo one can't paste multiple times. There is a small wrinkle if one is going forward in the stack or back, but the function fiddles that. It also "prevents" the double paste or a paste of nothingness.

Judson

Button Copy Card

on mouseup
global jgrcopypaste
clone this card
put the number of this card into jgrcopypaste
end mouseup


Button Cut Card

on mouseup
global jgrcopypaste
put the number of this card into jgrcopypaste
end mouseup


Button Paste Card

on mouseup
global jgrcopypaste
if jgrcopypaste is empty then
put "Error: No card has been cut or copied" into message
else
put the number of this card into foobar
if foobar < jgrcopypaste then --if the paste is earlier in the stack
put foobar+1 into foobar
else --if the paste is in situ or later in the stack
end if
set the number of card jgrcopypaste to foobar
go card foobar
end if
put empty into jgrcopypaste
end mouseup

Curry
Posts: 111
Joined: Mon Oct 15, 2007 11:34 pm
Location: USA
Contact:

Re: Buttons and backgrounds

Post by Curry » Tue Aug 10, 2010 10:27 pm

Nice! You can paste multiple times if you wish with a small modification, and rather than buttons or menus you could simply utilize commandKeyDown in the stack script.
Best wishes,

Curry Kenworthy

LiveCode Development, Training & Consulting
http://livecodeconsulting.com/

WordLib: Conquer MS Word & OpenOffice
SpreadLib: "Excel-lent" spreadsheet import/export
http://livecodeaddons.com/

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”