Bg & fg colours on static labels in dialogs for javascript button

Setting the following will result in a red bg with black fg. When the fg should be white.

    dialog.Control("static4").bg = "#ff0000";
    dialog.Control("static4").fg = "#ffffff";

Please give a small, self-contained example. (Don't worry about that, I can use your example from the other thread.)

It's working fine here:

Tried with the code below, which is based on simplified version of your button from the other thread.

Script Code:

function OnClick(clickData)
{
	// Main Dialog init
	var dialog = DOpus.Dlg;
	dialog.template = "Main Dialog";
	dialog.LoadPosition("Foo_Dialog_Position");
	dialog.title = "Directory Opus";
	dialog.detach = true;
	dialog.opacity = 220;
	dialog.icon = "info";
	dialog.Create();
	
	// init name with selected file stem if a file is selected in source tab
	var source = clickData.func.sourcetab;
	dialog.Control("static1").bg = "#ff0000";
	dialog.Control("static1").fg = "#ffffff";
	if (source.stats.selitems > 0) {
		dialog.Control("edit1").value = source.selected(0).name_stem;
		dialog.Control("edit1").SelectRange(0,-1);
	}
	
	// Main Dialog message loop
	while (true) {
		if (!dialog.GetMsg().result) break;
	}
}

Resources:

<resources>
	<resource name="Main Dialog" type="dialog">
		<dialog fontsize="12" height="180" lang="english" opacity="200" standard_buttons="ok,cancel" width="252">
			<control halign="left" height="8" name="static1" title="Enter a unique name for the icon set" type="static" valign="top" width="120" x="66" y="12" />
			<control halign="left" height="12" name="edit1" type="edit" width="112" x="66" y="24" />
			<control halign="left" height="8" name="static2" title="Large Icon Size" type="static" valign="top" width="47" x="66" y="48" />
			<control halign="left" height="8" name="static3" title="Small Icon Size" type="static" valign="top" width="47" x="66" y="61" />
			<control halign="left" height="12" name="edit2" number="yes" title="32" type="edit" width="19" x="114" y="47" />
			<control halign="left" height="12" name="edit3" number="yes" title="24" type="edit" width="19" x="114" y="60" />
		</dialog>
	</resource>
</resources>


did a backup and restored to default, getting same result.

annoying. first display is black text, click again and it displays properly,
image

I shall do a clean re-install and get back to you.
......
same after clean install.

Does my example code + resources work for you?

solved, your code works perfectly

must be position of my calls, many thanks :slight_smile:

Nope there is a bug, here is the updated script button I am using, enter a value of 0 and click OK to trigger static label, fg is black, click OK again and fg changes to white. Have tried moving the bg,fg (line 64) statements around, but getting same result.
Iconset maker v2.dcf (14.5 KB)

Fixed bug. Replaced the static text control with a new static text control exactly the same and is now working properly. Weird glitch. Many thanks for help.

There must've been something different about the old control or code, since merely replacing it with the exactly the same thing wouldn't make a difference.

Jon had a look at this as well thinks he knows what's going wrong. There's a change in the next update which should fix it.