No Node "Set is pressed" for button ?

Hello everyone,

Why there is no “set is pressed” node for a button ?
I put “Set is Enabled” instead.

My bet is they were designed as a fire & forget widgets, with simplicity and the most common button functionality in mind, robust but inflexible. As soon as you try something uncanny, it will not work.

Consider not using native buttons. Make a border, add the functionality you need, use those user widgets in place of the native buttons. You get absolute control this way.

2 Likes

Allright but,

I’m actually trying to save a button that was pressed earlier to save it to a savegame, and to load when the game opens.
otherwise, if it is not possible, I would try to do otherwise.

this is what I’ve moved to as well.

@anon42830630 , to save a “button” you would most likely think about saving an index for an array.

Like you have an array of buttons associated with a widget, the save file only cares about which index is “selected” when it is loaded. Same idea you’ll probably use for a graphics options menu for instance.

So usually the buttons are held as children to a horizontal box, vertical box, scroll box, etc, and then we can identify them by their index.

Get a reference to the container box and then you can “get children”.

1 Like

Allright, so,

So it would be to save the index of the pressed button in an Integer variable ?

I don’t know, I don’t want to complicate things too much, I’ll think about it or maybe do something else.

i dont think you’ll be able to get around the need to save/load preferences in a widget menu.

Its a lot easier if you separate from your main project and just make a simple version in a new project first.

You need a widget button that has a bool for if it is selected or not. When it is selected, change its color or something.

In another widget, make a container (like a vertical box) and put a few of those buttons in it.

When you click a button, toggle its “selected” bool. Then loop through all the other buttons and set them to be not selected.

The index of the one that was selected you can save, and then load that when opening the menu next time.

This is often called a radio box - if you google that term there is at least a few step by step tutorials on youtube that will walk you through.

I’d work just on the buttons selection first, then think about save/load second.

2 Likes

Thank you for this clear and understandable answer.

I will try that first.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.