Posted by
Stein Rørvik on
Sep 17, 2020; 2:15pm
URL: http://imagej.273.s1.nabble.com/How-to-bring-up-the-Foreground-Color-dialog-tp5023959p5023961.html
Thanks,
I usually add such short javascripts to my macros by just assembling a multi-line string and then pass it to eval function; that makes it more readable than a long one-liner. Your code works fine:
//Set Foreground Color dialog:
javascript = "";
javascript += "c =Toolbar.getForegroundColor();\n";
javascript += "cNew = new ColorChooser('select foreground', c, false).getColor();\n";
javascript += "Toolbar.setForegroundColor(cNew);";
eval("script", javascript);
This also works for the background:
//Set Background Color dialog:
javascript = "";
javascript += "c =Toolbar.getBackgroundColor();\n";
javascript += "cNew = new ColorChooser('select background', c, false).getColor();\n";
javascript += "Toolbar.setBackgroundColor(cNew);";
eval("script", javascript);
Stein
-----Original Message-----
From: ImageJ Interest Group <
[hidden email]> On Behalf Of Michael Schmid
Sent: 17. september 2020 15:10
To:
[hidden email]
Subject: Re: How to bring up the Foreground Color dialog
Hi Stein,
here is a JavaScript example:
c=Toolbar.getForegroundColor();
cNew=new ColorChooser("select foreground", c, false).getColor();
Toolbar.setForegroundColor(cNew);
I don't know a specific macro command, but you can use 'eval' to use
JavaScript code in a macro. It's one long line; if the mailer should
split it, you have to make one line out of it:
eval('js','Toolbar.setForegroundColor(new ColorChooser("select
foreground", Toolbar.getForegroundColor(), false).getColor());');
The same should work for the background (I have not tried that).
---
Setting the foreground to 'red' etc:
With the recent daily builds, right-click the color picker icon and you
have a choice of the most common colors.
Nevertheless, I agree that it would be nice to have the TextField at the
bottom of the CP accepting input. It looks fairly simple - just that
someone would have to do it...
Michael
________________________________________________________________
On 17.09.20 13:53, Stein Rørvik wrote:
--
ImageJ mailing list:
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&data=02%7C01%7Cstein.rorvik%40sintef.no%7Cb609b9d4cf8f4a88534a08d85b0b0fad%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C1%7C637359450363463940&sdata=X1FkcXS53WiyHs5bEpFYJ5pXQLM3WLt6iANUoZsOCkk%3D&reserved=0--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html