
Drawing on layers ... or not

ChrLie
With the following code:
function DrawStuff(string gname, string layer, variable isChecked) if(isChecked) SetDrawLayer/W=$gname $layer DrawText 0.2,0.2,"stuff drawn!" else SetDrawLayer/W=$gname/K $layer endif end
I can do:
•display •DrawStuff("Graph0", "ProgBack", 1) •DrawStuff("Graph0", "ProgBack", 0)
Text will first appear on Graph0, and the last line will take it off. So far so good.
Then I use
function doPanel(string win) NewPanel/N=ctrlPanel/W=(0,0,100,100) /EXT=0/HOST=$win CheckBox checkGrid, win=ctrlPanel, pos={15,25},size={61.00,16.00},proc=myCheckProc CheckBox checkGrid,win=ctrlPanel,title="draw stuff",value=0 end Function myCheckProc(cba) : CheckBoxControl STRUCT WMCheckboxAction &cba string HostName, cmd string layer = "ProgBack" switch( cba.eventCode ) case 2: // mouse up HostName = StringFromList(0,cba.win,"#") sprintf cmd "DrawStuff(\"%s\", \"%s\", %g)", HostName, layer, cba.checked print cmd drawStuff(HostName, layer, cba.Checked) break case -1: // control being killed break endswitch return 0 End
and add a sub-window to "Graph0":
doPanel("Graph0")
Now clicking the "draw stuff" checkbox should cause the same as the commands above, but nothing is drawn, at least not on my system, which is:
print IgorInfo(3) OS:macOS;OSVERSION:10.15.7;LOCALE:US;IGORFILEVERSION:9.01B01;
I might be missing something but I just don't seen it. Maybe sub-window syntax?
Solved!
I forgot to add /W=$gname to DrawText in the top function.
D'Oh!
EDIT:
Why is that? One looks since more than a day for the error and as soon it has been posted it jumps right into the face!
April 7, 2022 at 02:02 am - Permalink
This is a common phenomenon. See here:
https://en.wikipedia.org/wiki/Rubber_duck_debugging
April 7, 2022 at 02:38 am - Permalink
Well, either way, the forum proofs to be extraordinary useful!
Probably better that way than being caught by colleagues speaking to a duck!
April 7, 2022 at 06:14 am - Permalink
Perhaps in the debugger there should be a little rubber duck picture with the caption "Talk to me"
Andy
April 7, 2022 at 06:47 am - Permalink
I like that, Andy! I'll talk to Jim Prouty (Mr. Debugger) about it...
April 7, 2022 at 09:38 am - Permalink