Download

UMG: Why a lot of properties don't have get function or other way to get their value?

Hi,

Like the layout offset property, it has set function, but no way to get it’s value.
The checkbox’s check state has get/set function but it says it is protected…

Others I don’t remember now.

Don’t understand.

The checkbox protected issue is a bug in 4.4, it should be fixed in 4.5.

The reason some properties have only set and not get is because it was a design decision in Slate not to allow Slate to become a backing of state information. A lot of UI engines allow the user to use the UI objects as the source of your game or application state - generally considered a bad idea. To prevent this, Slate only allows the user to Get information set by a user, so because the checkbox state is set by the user you can get it, but the user doesn’t set the offset property, so you can’t. UMG mirrors this same restriction.

May re-evaluate in the future, do you have a reason for getting the offset, or are you just curious?

I see, I just installed the 4.5 preview, the protected issue is fixed, but seems found a “issue?”: the IsHovered function is not context sensitive with selected widget…

I want to get the offset property, cause I need to set the widget’s position at runtime(I posted another thread:add button at runtime), I get the mouse position and use the parent widget’s offset info to set the widget’s position, it seems work, but I just get the value from designer I need to get it’s value at runtime. Or is there another way to do this?

Layout is complicated. Slate doesn’t know where things are located on screen until a layout pass happens, there’s a lot involved in determining a widgets position on screen each frame. You would have to do it inside of a Tick where you had access to the widget’s geometry information. That structure is exposed to UMG, but only a subset is mapped for blueprint access, we may need to add more over time. The easiest solution is to check the IsHovered status of the widgets you care about.