Designing a tab control

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
kolia
Posts: 82
Joined: Thu May 28, 2015 3:53 pm

Designing a tab control

Post by kolia » Tue Sep 08, 2015 6:40 pm

Hello,

I wan't to understand how the tab desigh control works. So far when I put a control "Inside" a tab, it is visible either when I click on Tab 1 or Tab 2. Is there a way to have controls belonging to specific tabs meaning that it becomes automatically invisible when another tab is selected?
Thank you
Nicolas
Nicolas
LC 7.1 on Windows 8.1 and on MAC OS 10.10.5 Xcode 6.4 - 7.1

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

Re: Designing a tab control

Post by dunbarx » Tue Sep 08, 2015 7:05 pm

Hi.

If I understand the question, you are placing an image or other control(s) within the rect of the tab panel control? And want to show or hide those objects based on the user's choice? If so, then simply use the menuPick message in the script of the tab panel itself to manage the visibility of any of those objects. If you need more help with what I just said, write back.

Craig Newman

kolia
Posts: 82
Joined: Thu May 28, 2015 3:53 pm

Re: Designing a tab control

Post by kolia » Tue Sep 08, 2015 7:20 pm

Hi,
Yes this what I want to do. I thought that Tab control had some internal awareness to do that automatically (I'm coming from other dev environment). By the way, if I may, I think it should because it makes the graphics design quite cumbersome
Thanks for the tip
Nicolas
Nicolas
LC 7.1 on Windows 8.1 and on MAC OS 10.10.5 Xcode 6.4 - 7.1

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

Re: Designing a tab control

Post by Klaus » Tue Sep 08, 2015 9:30 pm

Hi Nicolas,

here is how I ususally create and script a TABbed button control:
1. I first create some groups that should appear for each "tab"
2. I name these groups like the TABS of the button
3. Place them where they should appear on the "tabs"
4. Then I use the extra parameter of "menupick" that only comes with TABbed button -> menuPick chosenItem,previousTab
and script the button like this:

Code: Select all

on menupick tNewGroup, tOldGroup
  lock screen
  hide gro tOldGroup
  show grp tNewGroup
  unlock screen
end menupick
Hope that helps!


Best

Klaus

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

Re: Designing a tab control

Post by dunbarx » Tue Sep 08, 2015 10:13 pm

Nicholas.
if I may, I think it should because it makes the graphics design quite cumbersome
I see your point, but it also restricts the flexibility and power of the control. As Klaus showed, and this is just one adorable way to do it, just a little bit of rolling your own opens limitless other functional capabilities. Why, the kernel of the required handler is even pre-loaded for you. You can do all that you are asking for in a handful of lines of code.

Craig

kolia
Posts: 82
Joined: Thu May 28, 2015 3:53 pm

Re: Designing a tab control

Post by kolia » Tue Sep 08, 2015 10:27 pm

Hi Klaus
This is almost what I did. But I don't quite understand the syntax of point 4. I'd love to have some more understanding. Thanks
All the best
Nicolas
Nicolas
LC 7.1 on Windows 8.1 and on MAC OS 10.10.5 Xcode 6.4 - 7.1

kolia
Posts: 82
Joined: Thu May 28, 2015 3:53 pm

Re: Designing a tab control

Post by kolia » Tue Sep 08, 2015 10:37 pm

Hi Graig
I see your point. I did use the group object, which is a fantastic implementation especially when you embed one group in another and so forth. But again when you are in the design phase, you have to play with visible / invisible to free space in order to place other controls. May it is just a matter of changing habits ;)
All the best
Nicolas
Nicolas
LC 7.1 on Windows 8.1 and on MAC OS 10.10.5 Xcode 6.4 - 7.1

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

Re: Designing a tab control

Post by Klaus » Wed Sep 09, 2015 12:50 pm

Hi Nicolas,
kolia wrote:But I don't quite understand the syntax of point 4. I'd love to have some more understanding.
ususally the "menupick" command has ONE parameter, the menuitem the user has chosen, right?

This handler will also have a SECOND parameter, but only for the TABbed button control,
and that is the TAB that is currently selecte BEFORE you click the new one.
-> menupick NewChosenTab,PreviouslyChosenTab

Taht is why we can hide and show groups so easily without haveg to loops through them and
hide all befoe showing the selected one or whatever we might need to do without this parameter.

Please check these gerat stack to get more of the basics of Livecode, maybe start with stack "Controls" :D
http://www.hyperactivesw.com/revscriptc ... ences.html


Best

Klaus

kolia
Posts: 82
Joined: Thu May 28, 2015 3:53 pm

Re: Designing a tab control

Post by kolia » Wed Sep 09, 2015 2:55 pm

Hi Klaus,
I got it, this is so smart.
Thank you
Nicolas
Nicolas
LC 7.1 on Windows 8.1 and on MAC OS 10.10.5 Xcode 6.4 - 7.1

kolia
Posts: 82
Joined: Thu May 28, 2015 3:53 pm

Re: Designing a tab control

Post by kolia » Wed Sep 09, 2015 3:53 pm

Hi Klaus
I have a weird error: button "Tab Menu": execution error at line 2 (Chunk: can't find background), char 1

Code: Select all

on menuPick new, old
   hide grp old
   show grp new
end menuPick
I don't understand what is trigerring it
Nicolas
Nicolas
LC 7.1 on Windows 8.1 and on MAC OS 10.10.5 Xcode 6.4 - 7.1

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

Re: Designing a tab control

Post by Klaus » Wed Sep 09, 2015 4:45 pm

Hi Nicolas,

maybe an example will help tpo understand the principle:
A TABbed buttoncontrol with these TABs:
tab1
tab2
tab3

Now you need to have three groups whith the SAME name as the TABs:
group "tab1"
group "tab2
group "tab3"

When the menupick handler is being executed, the parameters will of course contain
the ACTUAL TABs involved!

Example: User clicks "tab2" and the previously selected/visible group was "tab1" then
the parameters of the handler will look like this:

Code: Select all

on menupick new,old
  ## new = "tab2
  ## old = "tab1"
...
But you obviously do not have a group named NEW nor OLD, so you get this error.
Come on, I know you know what a parameter is! :D


Best

Klaus

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

Re: Designing a tab control

Post by dunbarx » Wed Sep 09, 2015 4:48 pm

Hi.

Are you sure you renamed the actual tabs "New" and "Old"? Otherwise, out of the box, the handler will be looking for a group named, say, "Tab 1". If you check the variable pane, you can see the values for the two variables "new" and "old". Make sure they reference groups that actually exist.

Craig

kolia
Posts: 82
Joined: Thu May 28, 2015 3:53 pm

Re: Designing a tab control

Post by kolia » Wed Sep 09, 2015 5:11 pm

Hi,
I just omitted to design the group in the second tab. I was focusing on the first tab which is the most important one. Thanks so much for your patience, and your explainations.
Nicolas
LC 7.1 on Windows 8.1 and on MAC OS 10.10.5 Xcode 6.4 - 7.1

Post Reply