Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Raise canvas item to top

by Phinix (Acolyte)
on Nov 17, 2012 at 09:00 UTC ( #1004291=perlquestion: print w/replies, xml ) Need Help??
Phinix has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

Recently I have been working on an interactive tree structure, where the user can click on bound canvas items at various "nodes" on the tree to perform different tasks.

I am using the createWindow method to set up the node buttons with background images and bindings to click. Each node image also has a label below it (also an item on the same canvas) which is bound to an enter/leave that pops up a tooltip window which I also create using the createWindow method.

The problem is even though this popup window should be on top since it is created last, parts of it are still tucked under the node images.

I have tried giving my popup windows a tag and using $canvas->raise('tag'), however this does not work either.

I don't know if the reason is due to the node images being createWindow canvases themselves but that doesn't seem like it should matter. To me, since they are all children put on the main canvas using create methods they should all be in the same stack regardless of type.

My question is how can I reliably keep my popup windows on top? I can provide code samples if needed but to be honest the code for this project has got to be pretty complex at this point.

Replies are listed 'Best First'.
Re: Raise canvas item to top
by zentara (Archbishop) on Nov 17, 2012 at 10:43 UTC
    In my experience with createWindow on a canvas, you can only hide the window, by placing something above it, to cover it. See embedding xterm into a Tk app for example.

    If you want to do alot of tag play, it would probably be best to stick to a single canvas, and not embed more canvases. What are you doing exactly, where you absolutely need to embed secondary canvases? Why not just stick to having one canvas?

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: Raise canvas item to top
by Anonymous Monk on Nov 17, 2012 at 09:24 UTC
Re: Raise canvas item to top
by Phinix (Acolyte) on Nov 17, 2012 at 19:07 UTC

    I am creating right and left mouse click bindings to the node items on the main canvas. I need them to be images that blend into the main canvas background. I tried just creating each image on the main canvas, setting it to a localized variable in the process, then binding to that variable, however bind complains saying it needs an instance of a package or some such to set up bindings.

    There may be another way to set up bindings on a canvas item using it's internal stack ID that I am not aware of, this is just the only way I know to make it work. Bind never complained about being set to createWindow objects on a canvas, while others do. Again, they are all items created on the same main canvas, so it theoretically shouldn't matter what they are, they should all be bind-able and follow the stacking rules.

    Perhaps it works that way in newer versions of Perl/Tk. I am currently using 5.12.

    For right now I am just putting the main info window for all the nodes in one fixed location (a corner) that doesn't overlap anything, so that is working for now. It would be nice however to be able to place the popup info windows adjacent to the actual item without it being covered.

    Thanks for the feedback. Especially Mr. Zentara. You contribute so much around here, I just thought you deserved a special thanks!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1004291]
Approved by Perlbotics
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2018-06-25 16:35 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (127 votes). Check out past polls.