Hi All,

I am writing code Perl TK. I am want to popup a widget such as “entry” or “label” at the mouse location in a tree widget. I have been trying ideas similar to what I have seen done with popup menu. I have read your peace “Tk::Wm::Popup” on CPAN. <\P>

"...For this discussion, we'll use the simple term dialog to refer any widget that pops up and awaits user interaction, whether it be a Menu, a special purpose Toplevel, or any of the dialog-type widgets, including, but not limited to, ColorEditor, Dialog, DialogBox, ErrorDialog, FileSelect, FBox, getOpenFile and getSaveFile. ..."

I assume that I should be able to able to popup simple widgets. Here is my test code.

use Tk; use Tk::Entry; use Tk::Tree; use Tk::Notebook; use warnings; use strict; my $mw = MainWindow->new(); my $nb = $mw->NoteBook( -font => 'Tahoma 8 bold', )->pack( -side => 'top', -anchor => 'ne', -expand => 1, -fill => 'both', ); my $tb = $nb->add( 'Tab 1', -label => 'Tab1', ); my $tree = $tb->Scrolled( 'Tree', -background => 'snow', -selectmode => 'extended', -selectbackground => '#E0FFCC', -selectforeground => 'red', -highlightthickness => 0, -relief => 'ridge', -borderwidth => 2, -scrollbars => 'osoe', -drawbranch => 'true', -indicator => 'true', -selectborderwidth => -1, -selectmode => 'extended', #-browsecmd => \&my_command, )->pack(-side => 'top', -anchor => 'nw', -expand => 1, -fill => 'both', ); # ##================================= # ## popup menu works fine # ##================================= # my $mb = $tree->Menu; # $tree->bind("<Button-3>" => sub { $mb->Popup( -popover => "cursor", # -tearoff => 0, # -popanchor => 'nw', # -overanchor => 'ne' # ) # } # ); # # my $mdel = $mb->cascade( -label => 'Delete', # -tearoff => 0, # ); # # $mdel->command( -label => "Delete", # -command => sub{ my @E = $tree->info( 'selection' ); # foreach my $e ( @E ) # { # $tree->delete( 'entry', $e); # } # } # ); ##================================= ## popup an entry that does NOT work ##================================= my $w = $tree->Frame(); $w->label( -text => 'popup label' ); $tree->bind("<Button-3>" => sub{ $w->Popup( -popover => "cursor", -popanchor => 'nw', -overanchor => 'ne' ) } ); MainLoop;

In reply to How to popup a widget such as “entry” or “label” at the mouse location by smh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.