| View previous topic :: View next topic |
| Author |
Message |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Thu Oct 04, 2007 3:25 am Post subject: Tab Question |
|
|
Hopefully this is a basic VDS question.
I need to create Tabs dynamically for a TAB element at runtime.
Actually creating them is easy. My challenge is how to handle the CLICK events since I don't know the Tab names (Not the element name but the individual tabs) prior to runtime.
I thought I could try adding a non-character at the end of the tab name then parse all CLICK events but non-characters show as a box. I would use a space but some of the tab names might contain spaces.
Any ideas? |
|
| Back to top |
|
 |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Thu Oct 04, 2007 11:31 am Post subject: |
|
|
The info on how to use dynamic tabs is here... somewhere.
It's been a long time since I wrote an application that used dynamic tabs. Below is some sample code. I just hope all the required bits are there...
This application had 4 tabs,but the user could select how many tabs were visible, or hidden - as well as which ones were visible or hidden. Plus the user could rename the tabs.
| Code: | gosub RegReadTabNames
DIALOG CREATE,Dynamic TABs example,-1,0,400,250
DIALOG ADD,TAB,TAB1,0,1,150,200,%%Tabs
DIALOG SHOW
:Evloop
wait event
%E = @event()
if @not(@null(%E))
if @equal(%E,%%Tab1%%Click) @equal(%E,%%Tab2%%Click) @equal(%E,%%Tab3%%Click) @equal(%E,%%Tab4%%Click)
%C = %E
%D = tabclick
else
%D = %E
end
end
%E =
goto %D
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# TAB CLICK EVENTS
:TabClick
gosub RegReadTabNames
if @equal(%C,%%tab1%%click)
%U = Group 1CLICK
elsif @equal(%C,%%tab2%%click)
%U = Group 2CLICK
elsif @equal(%C,%%tab3%%click)
%U = Group 3CLICK
elsif @equal(%C,%%tab4%%click)
%U = Group 4CLICK
else
%U = evloop
end
goto %U
:Group 1CLICK
# do something
goto evloop
:Group 2CLICK
# do something
goto evloop
:Group 3CLICK
# do something
goto evloop
:Group 4CLICK
# do something
goto evloop
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# GOSUBS
:RegReadTabNames
# READ GROUP NAMES FROM REGISTRY
%%tab1 = @regread(default,,tab1,Group 1)
if @equal(1,@regread(default,,Hide Group 2,0))
%%tab2 =
else
%%tab2 = @regread(default,,tab2,Group 2)
end
if @equal(1,@regread(default,,Hide Group 3,0))
%%tab3 =
else
%%tab3 = @regread(default,,tab3,Group 3)
end
if @equal(1,@regread(default,,Hide Group 4,1))
%%tab4 =
else
%%tab4 = @regread(default,,tab4,Group 4)
end
# HIDE HIDDEN TABS
#4 TABs showing
if @both(%%tab2,@both(%%tab3,%%tab4))
%%tabs = %%tab1@chr(124)%%tab2@chr(124)%%tab3@chr(124)%%tab4
#3 TABs showing
elsif @both(%%tab2,%%tab3)
%%tabs = %%tab1@chr(124)%%tab2@chr(124)%%tab3
elsif @both(%%tab2,%%tab4)
%%tabs = %%tab1@chr(124)%%tab2@chr(124)%%tab4
elsif @both(%%tab3,%%tab4)
%%tabs = %%tab1@chr(124)%%tab3@chr(124)%%tab4
#2 TABs showing
elsif %%tab2
%%tabs = %%tab1@chr(124)%%tab2
elsif %%tab3
%%tabs = %%tab1@chr(124)%%tab3
elsif %%tab4
%%tabs = %%tab1@chr(124)%%tab4
end
exit
|
_________________ cheers
Dave |
|
| Back to top |
|
 |
uvedese Contributor


Joined: 21 Jan 2006 Posts: 169 Location: Spain
|
Posted: Thu Oct 04, 2007 2:29 pm Post subject: |
|
|
Hi Aslan
A very easy and no professional solution: use my "TabSimulado" code for make it.
The user can create the TABS that it wants.
Information/download site:
http://vds.uvedese.es/index.php?option=com_content&task=view&id=45&Itemid=27
Good luck
______________
uVeDeSe
______________
Last edited by uvedese on Wed Apr 02, 2008 7:23 pm; edited 1 time in total |
|
| Back to top |
|
 |
vtol Valued Contributor


Joined: 05 Feb 2004 Posts: 656 Location: Eastern Indiana
|
Posted: Thu Oct 04, 2007 7:12 pm Post subject: |
|
|
Dave the code works great, just needs the following added at end:
uvedese
Mucho glacious Simulador de Tabs, grande  |
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Thu Oct 04, 2007 10:06 pm Post subject: |
|
|
Hey Thanks Dave,
This works great for a pre-defined number of tabs but what I'm working on there might be 4 tabs or possibly 20 tabs.
I think I'm going to have to just add a @tab() char at the end of each tab name, then just parse it. To give you an idea of what is going on, I'm dealing with accounts and each account has its own tab. Luckily all the tabs will have the same elements in which I track the data changes in a table. So basically, I'm just doing a data refresh each time a tab is clicked.
uvedese,
I'd like to see you example however, Geocities is blocked here. Would you mind sharing it here on VDSWORLD?
Thanks again  |
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Thu Oct 04, 2007 10:47 pm Post subject: |
|
|
Well crap it looks like using @tab() in the names creates a box too
I don't want to use spaces since the name could potentialy have spaces in it.
Edit: Unless someone knows how trick VDS into allowing DBL spaces as a delimiter.
B2TDB |
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Thu Oct 04, 2007 11:25 pm Post subject: |
|
|
Aslan,
Try using '^' as your separator. That character isn't used much _________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Fri Oct 05, 2007 12:29 am Post subject: |
|
|
Hi Bill
Hope you're doing well and glad to see you on the forum again
Won't the "^" character show up on the tab?
I tried a different approach taking advantage or ERRORTRAP
Here's a start
| Code: | %%Tabs = Account 1|Account 2|Account 3
option errortrap,error
Title Dynamic Tabs
DIALOG CREATE,Dynamic Tabs,-1,0,568,393
DIALOG ADD,TAB,TAB1,89,17,532,291,%%Tabs
DIALOG ADD,EDIT,NewTab,32,123,180,19
DIALOG ADD,BUTTON,ADD,32,403,64,18,ADD
DIALOG ADD,BUTTON,AddData,321,463,64,24,AddData
DIALOG ADD,EDIT,Newdata1,322,89,88,19,Newdata1
DIALOG ADD,EDIT,Newdata2,352,89,88,19,Newdata2
DIALOG ADD,EDIT,Newdata3,322,271,102,19,Newdata3
DIALOG ADD,EDIT,Newdata4,352,271,256,19,Newdata4
DIALOG ADD,TEXT,Col1,325,37,,,Column 1:
DIALOG ADD,TEXT,Col2,354,37,,,Column 2:
DIALOG ADD,TEXT,Col3,325,219,,,Column 3:
DIALOG ADD,TEXT,Col4,355,219,,,Column 4:
DIALOG ADD,TEXT,NewTabTx,35,38,,,New Tab Name:
DIALOG ADD,LINE,LINE1,129,38,490,183
DIALOG ADD,TABLE,TABLE1,129,38,490,183,Column 1[80]|Column 2[80]|Column 3[80]|Column 4[250]
DIALOG ADD,TEXT,TEXT1,35,308,,,"@ Index:"
DIALOG ADD,EDIT,INDEX,32,359,23,19
DIALOG SHOW
:Evloop
wait event
%E = @event()
goto %E
:TabCLICK
info You clicked on Tab @chr(34)@substr(%E,1,@sum(@len(%E),-5))@chr(34)
goto evloop
:ADDBUTTON
%T = @dlgtext(NewTab)
%i = @dlgtext(INDEX)
%%TCITEM = @binary(DWORD,$1)@binary(DWORD,0)@binary(DWORD,0)@binary(DWORD,@addr("%T"))
%X = @SENDMSG(~TAB1,@SUM($1300,7),%i,%%TCITEM)
goto evloop
:AddDataBUTTON
List add,table1,@dlgtext(Newdata1)@tab()@dlgtext(Newdata2)@tab()@dlgtext(Newdata3)@tab()@dlgtext(Newdata4)@tab()
goto evloop
:ERROR
If @both(@equal(@error(E),12),@equal(@substr(%E,@sum(@len(%E),-5)),@len(%E)),CLICK))
goto TabCLICK
end
:Close
exit |
There is obviously more to do but I think it's a good start  |
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Fri Oct 05, 2007 2:15 am Post subject: |
|
|
uvedese,
I finally got to a location where I can access Geocities.
Your Tab Simulator is very cool .
I believe if you restucture it like a DSU and add resizing commands to it, that it would make a great DSU.
I love the fact that since you are using shapes to simulate tabs, it opens up a wide range of possibilities.
Nice work  |
|
| Back to top |
|
 |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Fri Oct 05, 2007 8:48 am Post subject: |
|
|
| Aslan wrote: | | This works great for a pre-defined number of tabs but what I'm working on there might be 4 tabs or possibly 20 tabs. |
It actually works great for any number of tabs from 1 to 4. For allowing a quantity of tabs from 1 to 20 just expand the code to suite up to 20 tabs.
You are going to have to set a limit to the numbers of tabs (whether it be 4 or 400), because your code has to have labels for all possible tabs.
The dynamic part of my code is that the user can:
- Name all the tabs
- Choose how many tabs to show
- Choose which tabs to show _________________ cheers
Dave |
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Fri Oct 05, 2007 2:37 pm Post subject: |
|
|
| DaveŽ wrote: | | You are going to have to set a limit to the numbers of tabs (whether it be 4 or 400), because your code has to have labels for all possible tabs. |
In general, I would agree if each tab was using its own set of elements.
However, for the purpose of the app I'm developing each tab will use the same set of elements, just different data which will be retrieved from a database in relation to the tab name. This means that I only use one Label that basically parses out the tab name from the CLICK event then processes the rest from it. Therefore, 400 tabs would still use only one label.
Note: My above code also allows for creating new tabs on the fly. It was just a basic example but can be easily expanded upon to include removing tabs, tab icons, reordering tabs...etc. |
|
| Back to top |
|
 |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Sat Oct 06, 2007 3:23 am Post subject: |
|
|
Ok, so then your original suggestion of using a non-visible character in the tab name, and then parsing the event to determine how to process the tab click would seem to be the way go - if you can get it to work.
But IMHO what you want to do is set a variable for each tab name. Show the variable to the user as the tab name. But use a numbered element name for the script to process. Have another look at the sample code I posted. But you are still going to have a maximum number of tabs pre-set in your code. i.e.
| Code: | :tab1
:tab2
:tab3
:tab4
:tab5
:tab6
:tab7
:tab8
:tab9
:tab10
:tab11
:tab12
:tab13
:tab14
:tab15
# process tab click
goto evloop
|
_________________ cheers
Dave |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|