Page 9 of 13
Re: TabBarGadget - Tabs like in a browser
Posted: Mon Mar 13, 2017 8:10 am
by STARGÅTE
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
Re: TabBarGadget - Tabs like in a browser
Posted: Thu Sep 07, 2017 2:49 pm
by Niffo
Here is my contribution to TabBarGadget : Added SetTabBarGadgetBackColor() and GetTabBarGadgetBackColor to be able to force the background color.
http://niffo.free.fr/TabBarGadget/
Re: TabBarGadget - Tabs like in a browser
Posted: Thu Sep 07, 2017 3:32 pm
by falsam
Thanks

Re: TabBarGadget - Tabs like in a browser
Posted: Thu Sep 07, 2017 4:40 pm
by davido
@Nifo,
Thank you.
Re: TabBarGadget - Tabs like in a browser
Posted: Thu Oct 05, 2017 5:08 pm
by falsam
Thanks Niffo ^-^
Re: TabBarGadget - Tabs like in a browser
Posted: Sun Feb 04, 2018 6:20 pm
by wombats
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.
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
Posted: Sun Feb 04, 2018 9:55 pm
by STARGÅTE
Hi wombats,
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
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:
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))
Re: TabBarGadget - Tabs like in a browser
Posted: Mon Dec 03, 2018 6:32 am
by GenRabbit
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)
Re: TabBarGadget - Tabs like in a browser
Posted: Mon Dec 03, 2018 7:53 am
by mestnyi
STARGÅTE wrote:Hi wombats,
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
As you can see, the
second defined event is call as
first.
[/code]
I asked Fred to change the order of the call, but alas.
viewtopic.php?f=3&t=62603
Re: TabBarGadget - Tabs like in a browser
Posted: Mon Dec 03, 2018 12:28 pm
by Dude
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
Posted: Mon Dec 03, 2018 12:29 pm
by Niffo
You can resize the gadget then call UpdateTabBarGadget()

Re: TabBarGadget - Tabs like in a browser
Posted: Mon Dec 03, 2018 12:42 pm
by Dude
Tried that, but it didn't work.

Here's my resize code:
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))
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:
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)
Is this not how it's meant to be used?
Re: TabBarGadget - Tabs like in a browser
Posted: Mon Dec 03, 2018 12:46 pm
by Niffo
Unlike PanelGadget(), TabBarGadget() does not handle containers, you have to handle them yourself.
Re: TabBarGadget - Tabs like in a browser
Posted: Mon Dec 03, 2018 1:02 pm
by Dude
Do you mean I have to put a ContainerGadget inside each TabBarGadget tab, with all gadgets inside those containers?
Re: TabBarGadget - Tabs like in a browser
Posted: Mon Dec 03, 2018 1:04 pm
by Niffo
Yes