Creating Elements Dynamically

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

Post Reply
bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Creating Elements Dynamically

Post by bidgeeman » Sun Nov 15, 2009 11:44 pm

Hello.

Rev tutorials show me how to drag and drop elemts into a stack....but say I need to create several hundred elements in RR like checkboxes. This would need to be done dynamically as the Rev interface cannot handle so many physical elements in the interface at once. It completely slows down my machine.

So my question is:
How can you create checkboxes dynamically in Rev?
Is it possible?

Cheers
Bidge

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte » Sun Nov 15, 2009 11:59 pm

hi bidge

well possible

set the style of the templateButton to "checkbox"
repeat with i=1 to 100
create button ("checkbox"&&i)
set the loc of it to random(100),random(110)
-- you get the idea
end repeat

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Post by bidgeeman » Mon Nov 16, 2009 12:02 am

ahh...thanks malte!!!

I am a video tutorial novice learning very slowly :)

Cheers
Bidge

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Mon Nov 16, 2009 12:46 am

Bidge
try this script, some of the options are just to show that you can code a lot of things into these checkboxes,

Code: Select all

on mouseUp
   reset the templatebutton
   set the style of the templatebutton to "checkbox"
   set the hiliteborder of the templatebutton to false
   set the tooltip of the templatebutton to "click me to make a change" -- optional
   -- you can set a lot more of the properties of the templatebutton here
   
   put the colornames into tColors
   put "on mouseUp" & cr &   "answer the short name of me"  & cr & "end mouseUp" into tScript
   put 50 into tButtonLeft -- start left position
   put 50 into tButtonTop -- start top position
   put 1 into tCounter
   put 3 into tCollums -- adjust for No of Collums
   put 3 into tRows -- adjust for No of Rows
   lock screen
   repeat with i= 1 to tCollums
      repeat with j = 1 to tRows
         create button 
         set the name of the last button to "myButton" & tCounter  -- optional 
         set the label of the last button to "Label of btn " & tCounter -- optional
         set the script of the last button to tScript -- optional
         set the foregroundcolor of the last button to any line of tColors -- optional and not advised
         
         set the top of the last button to tButtonTop
         add the height of the last button  + 4 to tButtonTop -- adjust
         
         set the left of the last button to tButtonLeft
         add 1 to tCounter
      end repeat
      put 50 into tButtonTop 
      add the width of the last button + 4 to tButtonLeft -- adjust
   end repeat
end mouseUp
regards
Bernd

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Post by bidgeeman » Mon Nov 16, 2009 12:55 am

WOW :shock:
Thanks for thet Bernd!!!!
These are the types of examples I cannot seem to find anywhere.

I thank you muchly :)
Bidge

Regulae
Posts: 136
Joined: Tue Oct 20, 2009 6:05 am

Post by Regulae » Mon Nov 16, 2009 2:44 am

Bernd,

That's a classic script, definitely one for the scrapbook!

Regards to fellow Rev-olutionaries.

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Mon Nov 16, 2009 10:46 am

Be aware that there are 'scriptLimits' that come into play when running a standalone. If you want to add scripts to these dynamic controls, they can be no longer than 10 lines; so if they need to be longer, you should delve into the message path, and more specifically behaviors, frontscripts and backscripts.
A good read on this topic is Richard Gaskin's article Extending the Runtime Revolution Message Path, which explains this in great detail and clarity.

HTH,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Post Reply