How do populate object into Tab Panel

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
Daross
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 23
Joined: Thu Jun 04, 2009 8:15 pm

How do populate object into Tab Panel

Post by Daross » Fri Jun 19, 2009 8:31 pm

Hi all,

I have to create a tab panel with 3 tab (Tab1, Tab2, Tab3.) and each table must have fields buttons etc.

I have tried to add the objects but do not remain in the individual tables

how Do add a object into single tab panel?


Thanks in advance

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

Post by FourthWorld » Fri Jun 19, 2009 8:58 pm

A tab control in Rev is a single object, and is not a container of other objects.

But cards and groups are containers, so you can either put the controls for each tab on separate cards after placing the tab into a group that's shared across all the cards, or put the controls into group and just swap the visibility of groups from the tab.

I tend to go the group route myself, in which I make a group for each tab using the name of that tab, and a script in the tab control something like this:

Code: Select all

on menuPick pItem
  repeat for each item tTab in "Tab 1,Tab 2,Tab 3" -- tab names
     set the vis of grp tTab to (tTab = pItem)
  end repeat
end menuPick
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Daross
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 23
Joined: Thu Jun 04, 2009 8:15 pm

Post by Daross » Sun Jun 21, 2009 10:47 am

Hi Richard,

Now I understand the functions of the Tab Panel.

Thanks.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Mon Jun 22, 2009 10:09 am

HI Daross,

TABBED buttons receive 2 (two) parameters with the "menupick" message:
1. the item chosen
2. the item that has been previously chosen!

So you could also script:

Code: Select all

on menuPick tNew,tOld 
   show grp tNew
   hide grp tOld
end menuPick
Best

Klaus

Daross
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 23
Joined: Thu Jun 04, 2009 8:15 pm

Post by Daross » Sat Jun 27, 2009 10:15 am

Hi Klaus,

I have seen and tried your script on the topic "Controls" to link:

http://support.runrev.com/scriptingconferences/

The link scripting conferences are a gold mine for us beginners and the 'learning is faster.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Sat Jun 27, 2009 11:22 am

Buongiorno Daross,

yes, that's true and I cannot understadnd why this is not visible on the startpage of RunRev.

In fact one has to explicitely serach for it, which is almost impossible if you do not know what to search for.

Anyway have a nice weekend :-)


Best

Klaus

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

Post by FourthWorld » Sat Jun 27, 2009 5:36 pm

Klaus, there is an attractive simplicity to your method, and if one has a very large number of tabs might even yield a performance benefit.

But the reason I settled on my more "brute force" method is with the aim of defensive programming: groups' visibility may be affected by many things, whether other scripts in my app or other tools in the IDE, and walking through each group related to the tabs ensures that all groups are in their expected state.

In this case the stylistic difference is minimal, and I see no harm in doing it either way. But as a general rule, in recent years I find myself adopting ever more defensive programming practices, even at the cost of a few clock cycles per click, to help reduce the range of things that can go wrong somewhere else down the road.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Sun Jun 28, 2009 11:18 am

Hi Richard,

I only wanted to show Daroos the "official MetaCard way" so knows at least two ways of dealing with tabbed buttons :-D

Your solution is really nice and I think I will adopt it, since I am a big fan of Monsieur Boole anyway ;-)


Best

Klaus

LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Re: How do populate object into Tab Panel

Post by LC4iOS » Wed Dec 18, 2013 10:39 pm

Just sharing ....

More tabs than grouped controls.

Code: Select all

on menupick new, old
   ## new = Name of the chosen menu/tab
   ## old = name of the previously chosen menu/tab
   
   Try
      hide grp old
   Catch lErr
   end try
   
   Try
      show grp new
   Catch lErr
   end try
   
   ## That's all we have to script :-)
   
   ## Remember that the message will look like:
   ## menupick "One","Two"
   ## So this script is quite comprehensible...
end menu pick
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

Post Reply