Changing Tabber text
BlitzPlus Forums/BlitzPlus Beginners Area/Changing Tabber text
| ||
I want to allow the users to custom name tabs from within the program, but I can't seem to figure how to rename the tabs myself. The way I currently have it set up is: Each Tabber has a panel with gadgets and a textfield. The textfield has the same text as the tab in which it is located. (this is done as each tab and textfield are created). When the user types into the textfield, I would like the current tab's text to change along with it. In this example a label simultaneously changes as the textfield changes. I would like the tab to that instead of the label. ** Bonus Help Question ** Is there a better way to do what am I doing in the codebox below? It would seem the Case structure would get very huge if I add all the code needed to check each tab/panels textfield (and subsequent gadgets). win=CreateWindow ("",0,0,800,700) ;create window Dim panel_num(10) Dim tab_num_name(10) Dim label_num_name(10) tab_num = CreateTabber(200,8,506,400,win) For z = 0 To 10 AddGadgetItem(tab_num,"Tab "+z) panel_num(z) = CreatePanel(4,4,494,368,tab_num,1) HideGadget panel_num(z) tab_num_name(z) = CreateTextField(4,4,100,20,panel_num(z)) SetGadgetText(tab_num_name(z),"Tab "+z) label_num_name(z) = CreateLabel(TextFieldText$(tab_num_name(z)),4,28,100,20,panel_num(z)) Next ShowGadget panel_num(0) ; Main Loop ############################################################################## Repeat id=WaitEvent() If id=$803 Then End If id=$401 Select EventSource() Case tab_num ed = EventData() For z = 0 To 9 HideGadget panel_num(z) Next ShowGadget panel_num(ed) Case tab_num_name(0) ;SelectGadgetItem(tab_num,0) SetGadgetText(tab_num ,TextFieldText$(tab_num_name(0))) SetGadgetText(label_num_name(0) ,TextFieldText$(tab_num_name(0))) Case tab_num_name(1) SetGadgetText(tab_num ,TextFieldText$(tab_num_name(1))) SetGadgetText(label_num_name(1) ,TextFieldText$(tab_num_name(1))) End Select End If Forever Last edited 2012 |
| ||
Okay, this *appears* to work. The only downside are some graphical artifacts near tab 10, but goes away once you click it. RemoveGadget InsertGadget SelectGadget <-Very Important ! The bonus question still stands though. Need a clean way to handle multiple tabs / panels etc.. Really loving BlitzPlus, makes my programs with hardcoded values much more versatile. :) win=CreateWindow ("",0,0,800,700) ;create window Dim panel_num(10) Dim tab_num_name(10) Dim label_num_name(10) tab_num = CreateTabber(200,8,506,400,win) For z = 0 To 10 AddGadgetItem(tab_num,"Tab "+z) panel_num(z) = CreatePanel(4,4,494,368,tab_num,1) HideGadget panel_num(z) tab_num_name(z) = CreateTextField(4,4,100,20,panel_num(z)) SetGadgetText(tab_num_name(z),"Tab "+z) label_num_name(z) = CreateLabel(TextFieldText$(tab_num_name(z)),4,28,100,20,panel_num(z)) Next ShowGadget panel_num(0) ; Main Loop ############################################################################## Repeat id=WaitEvent() If id=$803 Then End If id=$401 Select EventSource() Case tab_num ed = EventData() For z = 0 To 10 HideGadget panel_num(z) Next ShowGadget panel_num(ed) Print ed Case tab_num_name(0) SetGadgetText(label_num_name(0) ,TextFieldText$(tab_num_name(0))) RemoveGadgetItem (tab_num,0) InsertGadgetItem (tab_num,0,TextFieldText$(tab_num_name(0))) SelectGadgetItem (tab_num,0) Case tab_num_name(1) SetGadgetText(label_num_name(1) ,TextFieldText$(tab_num_name(1))) RemoveGadgetItem (tab_num,1) InsertGadgetItem (tab_num,1,TextFieldText$(tab_num_name(1))) SelectGadgetItem (tab_num,1) End Select End If Forever Last edited 2012 |
| ||
Yeah, that seems to work. Unless there is some unforeseen flaw. Hope others will find it useful. |