jlk@daimi.UUCP (J|rgen Lindskov Knudsen) (10/16/87)
Could anyone please explain to me, why the program-fragment below doesn't work? My intention is to have two canvas in a window, and that both canvas have a button on it, where the action of the buttons is to unmap the canvas with the button, and then map the other canvas. The two canvas are called can1 and can2. In the ideal world they should both be children of the ClientCanvas of the window (here called "can"). But this doesn't work -- it seems as if changing the Mapped attribute of the canvasses doesn't make any difference (except for input). In order to illustrate the intented behaviour, I have changed the parent of can1 to be the framebuffer, AND THEN ALL WORKS AS INTENDED W.R.T. CAN1. What's the problem? +---------------------------------+-------------------------------------------+ | Jorgen Lindskov Knudsen | | | Computer Science Department | phone: +45 6 12 83 55 | | Aarhus University | telex: 64767 aausci dk | | Ny Munkegade 116 | e-mail: jlk@daimi.dk -or- jlk@daimi.uucp | | DK-8000 Aarhus C, DENMARK. | | +---------------------------------+-------------------------------------------+ systemdict /Item known not { (NeWS/liteitem.ps) run } if /win framebuffer /new DefaultWindow send def { /PaintClient {random fillcanvas PaintCan1 PaintCan2 } def /FrameLabel (Main Window) def 50 50 1000 700 reshape } win send /can win /ClientCanvas get def /map win send /can1 framebuffer 300 200 createcanvas def can1 setcanvas 100 100 movecanvas /PaintCan1 { can1 setcanvas .9 fillcanvas [button1] paintitems } def /button1 (1) /action1 can1 50 50 /new ButtonItem send 20 20 /move 3 index send def /action1{ can2 mapcanvas (map can2 send\n) print can1 unmapcanvas } def [button1] forkitems /can2 can 300 200 createcanvas def can2 setcanvas 500 100 movecanvas /PaintCan2 { can2 setcanvas .7 fillcanvas [button2] paintitems } def /button2 (2) /action2 can2 50 50 /new ButtonItem send 20 20 /move 3 index send def /action2{ can1 mapcanvas (map can1 send\n) print can2 unmapcanvas } def [button2] forkitems can2 mapcanvas
don@BRILLIG.UMD.EDU (Don Hopkins) (10/17/87)
I typed in your code, and did the following: can1 == % This canvas's children can be seen canvas(300x200,unmapped,parent,complete,retained) can1 /Parent get == % this is the framebuffer canvas(1152x900,root,parent) can2 == % This canvas's children can't be seen canvas(300x200,transparent,parent,retained) can2 /Parent get == % This is ClientCanvas canvas(968x668,transparent,parent,retained) can2 /Parent get /Parent get == % This is FrameCanvas canvas(1000x700,parent,complete,retained) can2 /Parent get /Parent get /Parent get == % This is the framebuffer canvas(1152x900,root,parent) Maybe it's because the parent canvas of can2 is ClientCanvas, which is transparent, so can2 is transparent. I am at home right now and trying this out remotely, so I can't see what's going on on the screen. Try going "can2 /Transparent false put", and see if that works. Good luck! -Don