[SOLVED][GUI] Button state style?

I’m trying to create a version of the “FEButtonStyle1_Outlined_Chipped” menu button that stays lit after being pressed instead of fading back to the original state. Does anyone have any experience with this? I haven’t been able to figure it out.

FEButtonStyle1_Outlined_Chipped_Mikali = 
{
	type 	= "Button",
	buttonStyle = "FEButtonStyle1_Outlined_Chipped", --base this style on FEButtonStyle1_Outlined_Chipped
	stateIconOfs = { 0.0, 64/512 }, --64 is the offset between each button in the tga/dds file, 512 is the tga/dds height
	--stateIconCells = {disabled, OFF, mouseover when OFF, click when OFF, ON, mouseover when ON, click when ON, flash(?)}
	--the values in stateIconCells correspond to the offset chosen to point to the correct graphic in the tga/dds file used in IconBase below
	--example : mouseover when OFF = 2, so it will use the third color from the top (0 being the first one)
	stateIconCells = { 0, 1, 2, 3, 3, 3, 3, 4 },
	
	IconBase = {
		size = {0, 0},
		texture = "DATA:UI\\NewUI\\Styles\\ui_4kbuttons_Outlined_Chipped_Mikali.tga",
		uvRect = { 4/64, 4/512, 64/64, 64/512 },
		patch_X = { 7, -1, 7, 0 },
		patch_Y = { 7, -1, 7, 0 },
		patch_ResScale = RES_SCALE,
		Surface = { --this is managed by the shaders and I don't understand how it works, as changing values doesn't seem to change anything
			surface = "ui_multistate";
			{ prop = "state0", float3 = { 0.0, 0.0, 1.0 } },
			{ prop = "state1", float3 = { 0.0, 0.0, 0.0 } },
			{ prop = "state2", float3 = { 0.0, 0.0, 0.0 } },
			{ prop = "decal", float3 = { 0.0, 0.0, 0.0 } },
		},
	},
},

and the tga file needed on wetransfer : https://we.tl/vIVSyoV35o

Also, do not forget to add toggleButton = 1 in your button

1 Like

Thanks! I found a workaround where you have two buttons, but only show one at a time and hide the other. But this is even better!

Just for you to know, the problem was that you can’t modifiy the original button for the toggle version, because the shader sets the color (instead of my version where the color is in the tga file), and state0 (+tint0 which gives the color) defines OFF and ON whith the same behavior, so…

1 Like

What does that parameter do? I have not seen it before.

a “normal” button doesn’t keep its status to “pressed” when you release the mouse. So the ON state is only activated during the time you click the button.
Think of it as a monostable switch if you will.
If you want to have a bistable button, you need the toggleButton = 1 parameter.

It’s used in the objective button for example.

1 Like