AFWS
November 21, 2020, 1:39pm
#1
How can I initially disable a setting in a popup? Looks like this should work ,but it doesn’t. You have to toggle the setting first before it becomes disabled.
col = uiLayoutColumn(split, true);
uiLayoutSetEnabled(col, false);
const bool toggle = RNA_enum_get(&ptr, "toggle") == 1;
if (!toggle) {
uiLayoutSetEnabled(col, true);
}
else {
uiLayoutSetEnabled(col, false);
}
// setting to disable
uiItemR(col, &ptr, "enum", 0, NULL, ICON_NONE);
Doing something similar in python works in a panel.
col = split.column(align=True)
if not win.toggle:
col.enabled = True
else:
col.enabled = False
col.prop(win, "enum", text="")
jenkm
November 21, 2020, 3:05pm
#2
This should work.
col = uiLayoutColumn(split, true);
uiLayoutSetEnabled(col, RNA_enum_get(&ptr, "toggle") != 1);
Check what value of “toggle” you have initially.
AFWS
November 21, 2020, 4:36pm
#3
This still seems to give the same results.
jenkm
November 21, 2020, 6:09pm
#4
But are you sure that you have the value “toggle” = 1 initially?
I’m sure that when you explicitly set uiLayoutSetEnabled(col, false);
it works.
AFWS
November 21, 2020, 8:37pm
#5
OK, setting as false does work.
col = uiLayoutColumn(split, true);
uiLayoutSetEnabled(col, false);
uiItemR(col, &ptr, "enum", 0, NULL, ICON_NONE);
but this doesn’t
col = uiLayoutColumn(split, true);
uiLayoutSetEnabled(col, RNA_enum_get(&ptr, "toggle") != 1);
uiItemR(col, &ptr, "enum", 0, NULL, ICON_NONE);
/* properties */
RNA_def_boolean(
ot->srna, "toggle", 1, "Toggle", "Toggle");
jenkm
November 21, 2020, 8:50pm
#6
Maybe you just need “RNA_boolean_get()” , if it’s a “toggle”.
1 Like
AFWS
November 21, 2020, 8:59pm
#7
That was the issue. All this time I was using RNA_enum_get
and didn’t even realize it.
ankitm
November 22, 2020, 9:45am
#8
Aren’t there any warnings in the console that say don’t use enum for boolean ?