Re: add/edit a comment and store it with an image?
Posted by
vischer on
Feb 16, 2011; 8:17pm
URL: http://imagej.273.s1.nabble.com/add-edit-a-comment-and-store-it-with-an-image-tp3685672p3685674.html
Thanks Wayne, Michael and Bill for the answers.
In the meantime I have chosen to solve my problem with a modal dialog, so the solutions discussed here may be used in future when longer text is involved.
Obviously it is not easy to have simultaneous write access to a text window for both macro and user.
Bill, if I try your modified macros in a back-and-forth manner (F1 - F2 - F3 - F2), the text window "Description" is neither updated, nor is it editable anymore
It would be much simpler if the Log window was editable (similar to the Macro Recorder window).
Norbert Vischer
>
> This seems to work here (Mac OS 10.6.5; Java 1.6, ImageJ 1.45b4), :
>
> macro "Create Demo image [F1]"{
> newImage("A", "8-bit Ramp", 280, 250, 1);
> setMetadata("Info", "old text");
> }
>
> macro"Show Info [F2]"{
> info = getMetadata("Info");
> title1 = "Description";
> title2 = "["+title1+"]";
> f = title2;
> if (isOpen(title1)){
> selectWindow(title1);
> print(f, "\\Update:"); // clears the window
> }
> else
> run("Text Window...", "name="+title2+" menu");
> print(f, "new text");
> }
>
> macro "Store Info[F3]"{
> selectWindow("Description");
> str = getInfo("window.contents");
> selectWindow("A");
> setMetadata("info", str);
> }
>
> The window focus of "Store Info" has been explicitly set to "Description". Otherwise, the window.contents of the window "Macro" (which I had created to hold and run your test macros) was itself copied into the metadata.
>
> Bill Christens-Barry