TabBarGadget - Tabs like in a browser
Re: TabBarGadget - Tabs like in a browser
You can identify a right klick with EventType() and #PB_EventType_RightClick.
After this, you can use GetTabBarGadgetItemPosition(EventGadget(), #TabBarGadgetItem_Event), to identify the position of tab.
You can find an example of event handling here: Event types
After this, you can use GetTabBarGadgetItemPosition(EventGadget(), #TabBarGadgetItem_Event), to identify the position of tab.
You can find an example of event handling here: Event types
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Re: TabBarGadget - Tabs like in a browser
Here is my contribution to TabBarGadget : Added SetTabBarGadgetBackColor() and GetTabBarGadgetBackColor to be able to force the background color.
http://niffo.free.fr/TabBarGadget/
http://niffo.free.fr/TabBarGadget/
Niffo
Re: TabBarGadget - Tabs like in a browser
Thanks
➽ Windows 11 64-bit - PB 6.0 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti
Sorry for my bad english and the Dunning–Kruger effect.
Re: TabBarGadget - Tabs like in a browser
Thanks Niffo ^-^
➽ Windows 11 64-bit - PB 6.0 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti
Sorry for my bad english and the Dunning–Kruger effect.
Re: TabBarGadget - Tabs like in a browser
Hi,
I want to set the current tab after the tabs have all been added, but the first time the event is called, it reports that the current tab is -1 if the event has been called via BindEvent(). However, if the event is handled in the main event loop, it reports the current tab number correctly.
I want to set the current tab after the tabs have all been added, but the first time the event is called, it reports that the current tab is -1 if the event has been called via BindEvent(). However, if the event is handled in the main event loop, it reports the current tab number correctly.
Code: Select all
XIncludeFile "TabBarGadget.pbi"
Enumeration
#Window
#Gadget_TabBar
#Gadget_ListView_BindGadget
#Gadget_ListView_EventLoop
EndEnumeration
Procedure OnTabBarGadgetChange()
AddGadgetItem(#Gadget_ListView_BindGadget, -1, "New tab: " + Str(GetTabBarGadgetItemPosition(#Gadget_TabBar, #TabBarGadgetItem_Event)))
EndProcedure
OpenWindow(#Window, 0, 0, 800, 450, "TabBarGadget", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget)
TabBarGadget(#Gadget_TabBar, 0, 0, WindowWidth(#Window), #TabBarGadget_DefaultHeight, #TabBarGadget_None, #Window)
TextGadget(#PB_Any, 10, 40, 100, 20, "BindGadget:")
ListViewGadget(#Gadget_ListView_BindGadget, 10, 60, 100, 300)
TextGadget(#PB_Any, 120, 40, 100, 20, "Event Loop:")
ListViewGadget(#Gadget_ListView_EventLoop, 120, 60, 100, 300)
AddTabBarGadgetItem(#Gadget_TabBar, #PB_Default, "One")
AddTabBarGadgetItem(#Gadget_TabBar, #PB_Default, "Two")
AddTabBarGadgetItem(#Gadget_TabBar, #PB_Default, "Three")
BindGadgetEvent(#Gadget_TabBar, @OnTabBarGadgetChange(), #TabBarGadget_EventType_Change)
SetTabBarGadgetState(#Gadget_TabBar, 1)
PostEvent(#PB_Event_Gadget, #Window, #Gadget_TabBar, #TabBarGadget_EventType_Change)
Repeat
Define event = WaitWindowEvent()
If EventType() = #TabBarGadget_EventType_Change
AddGadgetItem(#Gadget_ListView_EventLoop, -1, "New tab: " + Str(GetTabBarGadgetItemPosition(#Gadget_TabBar, #TabBarGadgetItem_Event)))
EndIf
Until event = #PB_Event_CloseWindow
Re: TabBarGadget - Tabs like in a browser
Hi wombats,
It seems like it's the order of BindEvent events, as you can see here:
As you can see, the second defined event is call as first.
That meens, that "your" bind event to the TabBarGadget is called before my event, were I set the EventTab.
So you get -1 in your callback but 0 is the normal loop.
So the problem is how do you use "my" #TabBarGadget_EventType_Change event, if you post it.
____
A workaround for you:
It seems like it's the order of BindEvent events, as you can see here:
Code: Select all
Procedure ButtonHandler1()
Debug "ButtonHandler1"
EndProcedure
Procedure ButtonHandler2()
Debug "ButtonHandler2"
EndProcedure
OpenWindow(0, 100, 100, 200, 90, "Click test", #PB_Window_SystemMenu)
ButtonGadget(0, 10, 10, 180, 30, "Click me")
BindGadgetEvent(0, @ButtonHandler1())
BindGadgetEvent(0, @ButtonHandler2())
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
That meens, that "your" bind event to the TabBarGadget is called before my event, were I set the EventTab.
So you get -1 in your callback but 0 is the normal loop.
So the problem is how do you use "my" #TabBarGadget_EventType_Change event, if you post it.
____
A workaround for you:
Code: Select all
; use this callback to read the event tab
Procedure OnTabBarGadgetChange()
AddGadgetItem(#Gadget_ListView_BindGadget, -1, "New tab: " + Str(EventData()))
EndProcedure
;...
; Add the data parameter with the GetTabBarGadgetState()
PostEvent(#PB_Event_Gadget, #Window, #Gadget_TabBar, #TabBarGadget_EventType_Change, GetTabBarGadgetState(#Gadget_TabBar))
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Re: TabBarGadget - Tabs like in a browser
This is awesome. Any chance of getting a Module version of it?
I have moved it to work with module. Demo & main file. But I've but screwed up somewhere and have no idea what I have done wrong. (around 90% seems to work)
I have moved it to work with module. Demo & main file. But I've but screwed up somewhere and have no idea what I have done wrong. (around 90% seems to work)
Re: TabBarGadget - Tabs like in a browser
I asked Fred to change the order of the call, but alas.STARGÅTE wrote:Hi wombats,
It seems like it's the order of BindEvent events, as you can see here:As you can see, the second defined event is call as first.Code: Select all
Procedure ButtonHandler1() Debug "ButtonHandler1" EndProcedure Procedure ButtonHandler2() Debug "ButtonHandler2" EndProcedure OpenWindow(0, 100, 100, 200, 90, "Click test", #PB_Window_SystemMenu) ButtonGadget(0, 10, 10, 180, 30, "Click me") BindGadgetEvent(0, @ButtonHandler1()) BindGadgetEvent(0, @ButtonHandler2()) Repeat Event = WaitWindowEvent() Until Event = #PB_Event_CloseWindow
[/code]
viewtopic.php?f=3&t=62603
Re: TabBarGadget - Tabs like in a browser
Can the TabBarGadget be resized? I don't see a procedure for it in the source? Or am I blind? I need it to match the window's width when the user resizes the window.
Re: TabBarGadget - Tabs like in a browser
You can resize the gadget then call UpdateTabBarGadget()
Niffo
Re: TabBarGadget - Tabs like in a browser
Tried that, but it didn't work. Here's my resize code:
This works perfectly with a PanelGadget, but not the TabBarGadget (even with UpdateTabBarGadget() after it).
Maybe I don't understand how the TabBarGadget is meant to work. I assumed it was a simple drop-in replacement for the PanelGadget? Here's an example of the drop-in changes I made:
Is this not how it's meant to be used?
Code: Select all
; w and h are the width and height of the resized window, with some extra calcs thrown in.
ResizeGadget(#panel,#PB_Ignore,#PB_Ignore,w-(18*dpi),h-(verticalfactor*1.32)-(35*dpi))
Maybe I don't understand how the TabBarGadget is meant to work. I assumed it was a simple drop-in replacement for the PanelGadget? Here's an example of the drop-in changes I made:
Code: Select all
;Global panel=PanelGadget(#panel,10*dpi,43*dpi,0,0)
Global panel=TabBarGadget(#panel,10*dpi,43*dpi,0,0,0,#win_main)
;AddGadgetItem(#panel,-1,"Calendar ",img_cal)
AddTabBarGadgetItem(#panel,-1,"Calendar ",img_cal)
Re: TabBarGadget - Tabs like in a browser
Unlike PanelGadget(), TabBarGadget() does not handle containers, you have to handle them yourself.
Niffo
Re: TabBarGadget - Tabs like in a browser
Do you mean I have to put a ContainerGadget inside each TabBarGadget tab, with all gadgets inside those containers?