Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

TKX Popup Menu

by Jukari (Initiate)
on Feb 23, 2012 at 10:53 UTC ( [id://955698]=perlquestion: print w/replies, xml ) Need Help??

Jukari has asked for the wisdom of the Perl Monks concerning the following question:

O'Mighty Monks, I come before you weak and powerless to solve this problem, please grant me the wisdom and strength I require. I have searched long and hard, crossed the desert of google, tretched through the Perl jungle, but my vision eludes me still.

I am trying to create a TKX Cut,Copy,Paste popup menu. I've successfully been able to create the popup... but every attempt I've made to copy fails, selected text fails.

Also as an extra layer of problems all my windows are being created dynamically, I believe the problem may be that the window the mouse is on when calling the copy is not the same window that the copy is being copied from.... Below is code that I have cut up/ re hashed/ diced / and smashed, and nothing that comes out of it works.

sub popup { my $current_window = $_[0]; #value that has the screen it's on print "- $current_window\n"; my $pop_menu = $mw->new_menu; my $popup_menu = $pop_menu->new_menu(-tearoff => 0,); $popup_menu->add_command(-label => "Copy",-underline => 1,-command + => sub { [\&Tkx::event_generate,$mw,"<<Copy>>"] }); Tkx::bind($mw,"<3>", [ sub { my($x,$y) = @_; foreach my $i (@_) { print "$i\n"; ##Most of the values I get from TXK:Ev are ?? } $popup_menu->g_tk___popup($x,$y) } ,Tkx::Ev("%X", "%Y","%a","%B","%b","%c","%D","%d","%f","%h","% +K","%m","%o","%R","%E","%#","%s","%S","%t","%w") ] ); } popup($window);

Your help would be much appreciated. Thank you.
v/r
Anthony

Replies are listed 'Best First'.
Re: TKX Popup Menu
by Anonymous Monk on Feb 23, 2012 at 11:42 UTC

    Try increasing trace level, say $Tkx::TRACE=64;

    See also Tcl::pTk::Text already does everything Tk::Text does, comes with a popup/edit menu ... Tkx is work :)

      Thanks folks but I figured it out. Code Below creates a popup menu on location, and copys from the frame it's on.
      sub popup { Tkx::bind($mw,"<3>", [ sub { my($x,$y) = @_; my $current_window = Tkx::winfo('containing',$x,$y); my $pop_menu = $mw->new_menu; my $popup_menu = $pop_menu->new_menu(-tearoff => 0,); $popup_menu->add_command(-label => "Copy",-underline => 1, +-command => [\&Tkx::event_generate,"$current_window","<<Copy>>"]); $popup_menu->add_command(-label => "Paste",-underline => 1 +,-command => [\&Tkx::event_generate,"$current_window","<<Paste>>"]); print "window = $current_window\n"; $popup_menu->g_tk___popup($x,$y) } ,Tkx::Ev('%X','%Y') ] ); }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://955698]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-18 03:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found