Radiobutton discussion
Radiobutton discussion
https://lua-api.factorio.com/latest/LuaGuiElement.html
Just being nitpicky with the description of "radiobutton" type.
Functionally I think it is a little bit different from checkbox - when you click a selected checkbox it will deselect, but if you click a selected radio button it stays selected.
Just being nitpicky with the description of "radiobutton" type.
Functionally I think it is a little bit different from checkbox - when you click a selected checkbox it will deselect, but if you click a selected radio button it stays selected.
-
- Smart Inserter
- Posts: 2768
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: Documentation Improvement Requests
Additionally, their uses are also different. In a group of checkboxes, you can select multiple. In a group of radiobuttons, selecting one deselects the rest.guardog wrote: Mon Nov 28, 2022 1:57 am https://lua-api.factorio.com/latest/LuaGuiElement.html
Just being nitpicky with the description of "radiobutton" type.
Functionally I think it is a little bit different from checkbox - when you click a selected checkbox it will deselect, but if you click a selected radio button it stays selected.
(At least, this is how they're supposed to work. I don't know if Factorio has anything implemented for that automatically or not.)
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
Re: Documentation Improvement Requests
I believe you have to take care of toggling radiobuttons in your GUIs yourself. See here:FuryoftheStars wrote: Wed Nov 30, 2022 3:31 pm Additionally, their uses are also different. In a group of checkboxes, you can select multiple. In a group of radiobuttons, selecting one deselects the rest.
(At least, this is how they're supposed to work. I don't know if Factorio has anything implemented for that automatically or not.)
"radiobutton": A clickable element that is functionally identical to a checkbox, but has a circular appearance. Relevant event: on_gui_checked_state_changed
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
-
- Smart Inserter
- Posts: 2768
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: Documentation Improvement Requests
Yes, I had already read that, but every place where I've used radios have something implemented in the backend so any radios placed in the same container are automatically linked and thus change each other's states.Pi-C wrote: Fri Dec 02, 2022 2:01 pmI believe you have to take care of toggling radiobuttons in your GUIs yourself. See here:FuryoftheStars wrote: Wed Nov 30, 2022 3:31 pm Additionally, their uses are also different. In a group of checkboxes, you can select multiple. In a group of radiobuttons, selecting one deselects the rest.
(At least, this is how they're supposed to work. I don't know if Factorio has anything implemented for that automatically or not.)"radiobutton": A clickable element that is functionally identical to a checkbox, but has a circular appearance. Relevant event: on_gui_checked_state_changed
I suppose you could take the way it's written in the Factorio documentation to mean they don't have that, but I suppose (for clarity sake) I'd suggest making a mention in there one way or the other if the modder needs to handle it themselves. (I think this is what I was (poorly) trying to say before.)
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
Re: Documentation Improvement Requests
Consider this screenshot from a mod I'm working on: Each player can "own" only one vehicle at a time, but may have "locked" several vehicles simultaneously. The checkboxes are all contained in the same table. Which ones should be linked? All checkboxes in the same table, all checkboxes in the same row, or all checkboxes in the same column? The game doesn't know how you want your interface to work, so it seems reasonable that you have to implement some logic for toggling the boxes yourself.FuryoftheStars wrote: Fri Dec 02, 2022 2:54 pmYes, I had already read that, but every place where I've used radios have something implemented in the backend so any radios placed in the same container are automatically linked and thus change each other's states.Pi-C wrote: Fri Dec 02, 2022 2:01 pm"radiobutton": A clickable element that is functionally identical to a checkbox, but has a circular appearance. Relevant event: on_gui_checked_state_changed
(By the way: I could have used radio buttons for "Toggle ownership" to make it more obvious that only one of them can be active at any given time. However, with radio buttons, one would always be on -- but in this case it is intended that all buttons could be off.)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
-
- Smart Inserter
- Posts: 2768
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: Documentation Improvement Requests
I haven't done UIs in Factorio, so I don't know what they have for containers, but what I'm used to is being able to put in smaller containers within the main one for exactly that purpose. And if you have something more complex, then (again, what I'm used to) you have the ability to set a property that disables the automatic linking on a per radiobutton basis. Checkboxes are never done automatically in what I've used.Pi-C wrote: Fri Dec 02, 2022 4:47 pmConsider this screenshot from a mod I'm working on:FuryoftheStars wrote: Fri Dec 02, 2022 2:54 pmYes, I had already read that, but every place where I've used radios have something implemented in the backend so any radios placed in the same container are automatically linked and thus change each other's states.Pi-C wrote: Fri Dec 02, 2022 2:01 pm"radiobutton": A clickable element that is functionally identical to a checkbox, but has a circular appearance. Relevant event: on_gui_checked_state_changed
checkboxes.png
Each player can "own" only one vehicle at a time, but may have "locked" several vehicles simultaneously. The checkboxes are all contained in the same table. Which ones should be linked? All checkboxes in the same table, all checkboxes in the same row, or all checkboxes in the same column? The game doesn't know how you want your interface to work, so it seems reasonable that you have to implement some logic for toggling the boxes yourself.
(By the way: I could have used radio buttons for "Toggle ownership" to make it more obvious that only one of them can be active at any given time. However, with radio buttons, one would always be on -- but in this case it is intended that all buttons could be off.)
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
Re: Documentation Improvement Requests
I have only seen an automatic implementation like that once in all the frameworks I have encountered (ironically, it was the very first one, which gave me unreasonable expectations for the rest).FuryoftheStars wrote: Fri Dec 02, 2022 2:54 pm Yes, I had already read that, but every place where I've used radios have something implemented in the backend so any radios placed in the same container are automatically linked and thus change each other's states.
But yes, for the sake of clarity it's worth mentioning that there's no automagic behavior to radiobuttons.
Re: Documentation Improvement Requests
GUIs in Factorio have different types of containers, which may be nested. There are frames, flows, and scroll-panes. All of these have a "direction" property which determines whether the elements put into the container will be arranged horizontally or vertically. Additionally, there are tables that require a "column_count" property on creation. All elements added to a table will be arranged horizontally until there are more than column_count elements in a row; as soon as there are more elements than column_count, the row will be wrapped, and the element will be added as first column of the next row. Thus, there is no way to link all radio buttons in a row or all radio buttons in a column because you don't define rows and columns, but just add some elements. (If you want to add more columns to your table, but forget to change column_count, you may end up with shifted columns, e.g. a label above a checkbox above a textfield instead of 3 labels in column 1, 3 checkboxes in column 2, and 3 textfields in column 3.)FuryoftheStars wrote: Fri Dec 02, 2022 5:45 pm I haven't done UIs in Factorio, so I don't know what they have for containers, but what I'm used to is being able to put in smaller containers within the main one for exactly that purpose.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
-
- Smart Inserter
- Posts: 2768
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: Documentation Improvement Requests
Ok... but this doesn't change that I think it'd still be good to note that they're not automatically linked.Pi-C wrote: Mon Dec 05, 2022 9:37 amGUIs in Factorio have different types of containers, which may be nested. There are frames, flows, and scroll-panes. All of these have a "direction" property which determines whether the elements put into the container will be arranged horizontally or vertically. Additionally, there are tables that require a "column_count" property on creation. All elements added to a table will be arranged horizontally until there are more than column_count elements in a row; as soon as there are more elements than column_count, the row will be wrapped, and the element will be added as first column of the next row. Thus, there is no way to link all radio buttons in a row or all radio buttons in a column because you don't define rows and columns, but just add some elements. (If you want to add more columns to your table, but forget to change column_count, you may end up with shifted columns, e.g. a label above a checkbox above a textfield instead of 3 labels in column 1, 3 checkboxes in column 2, and 3 textfields in column 3.)FuryoftheStars wrote: Fri Dec 02, 2022 5:45 pm I haven't done UIs in Factorio, so I don't know what they have for containers, but what I'm used to is being able to put in smaller containers within the main one for exactly that purpose.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
Re: Documentation Improvement Requests
This is very important to note. The distinctive property of radiobuttons is not their "circular appearance" (which is just a customizable graphic), but their behavior when clicked while in the "on" state.guardog wrote: Mon Nov 28, 2022 1:57 am https://lua-api.factorio.com/latest/LuaGuiElement.html
Just being nitpicky with the description of "radiobutton" type.
Functionally I think it is a little bit different from checkbox - when you click a selected checkbox it will deselect, but if you click a selected radio button it stays selected.
Re: Radiobutton discussion
(Split from documentation improvement requests thread)
-> I noted for 1.1.79 that radiobuttons both don't unselect when clicked and are not linked in any way. Thanks to all.
-> I noted for 1.1.79 that radiobuttons both don't unselect when clicked and are not linked in any way. Thanks to all.