factoriolib / flib

A set of high-quality, commonly-used utilities for creating Factorio mods.
https://mods.factorio.com/mod/flib
MIT License
67 stars 15 forks source link

tab-and-content #24

Closed hahoyer closed 3 years ago

hahoyer commented 3 years ago

How to use tabs using flib? Haven't found any docu or examples. Can someone help me?

raiguard commented 3 years ago

For the gui module, it is like this:

{type = "tabbed-pane", children = {
  {type = "tab-and-content", tab = {type = "tab", caption = "Foo"}, content = {type = "flow", children = whatever}}
}}

For the gui-beta module it is like this:

{type = "tabbed-pane", tabs = {
  {tab = {type = "tab", caption = "Foo"}, content = {type = "flow", children = "whatever"}}
}}

I highly recommend using gui-beta. Sometime soon I'll get around to writing documentation for it so people know that it exists.

hahoyer commented 3 years ago

Thank you, that helped a lot. Would you mind including this example somewhere in the doc? As for gui-beta, how do I use that without the doc? It seems that it is not done just by replacing the require-statement. image

raiguard commented 3 years ago

Right now you have to read the source code to figure it out. gui.build() is similar, except for the tabs subtable as mentioned earlier. There is also an actions table that replaces the handlers subtable, and save_as is replaced by ref.

The way that the event handling works is completely different as well. I will take some time today to write some documentation.