Popup Menu problem while copy and paste..
- From: nagandla@xxxxxxxxx
- Date: Fri, 8 Feb 2008 05:31:50 -0800 (PST)
Hi All,
Here i am creating a popup menu for text widget..It contains
copy ,paste,delete functions..
I am copying & pasting the data in text widget .
After pasting data using popup menu , data is pasting perfectly into
text widget.
After that i am pressing the "DoSomething" button .
but it is not pressing on first click.For Second click its
working.This problem is in only windows but not in linux..
How i have to solve this problem?
Tk version is Tk-804.027.
Any one pls help?
Here i am copying the sample program...
use Tk;
my $mw = MainWindow->new();
my $txt ;
my $entry = $mw->Entry(-textvariable => \$txt, -background=>'white')-
pack();my $btn = $mw->Button(-text=>'Do Something',-command=>sub {
print "Doing Something bla bla ..\n";
# Doing Something.......
},-activeforeground=>'red')->pack();
$entry->bind("<Button-3>",\&popups);
my $cbm;
MainLoop;
sub copy_data
{
my($m) = @_;
print "Copy Data \n ";
my $cliptxt ;
eval
{
$mw->clipboardClear;
$mw->clipboardAppend($m->get());
};
if($@)
{
print "$@\n";
}
print "$txt Appended to CLIPBOARD\n";
}
sub paste_data
{
my($m) = @_;
print "Past Data \n ";
my $cliptext;
eval
{
$cliptext = $mw->SelectionGet(-selection => "CLIPBOARD");
};
return unless (length($cliptext));
$m->insert('end',$cliptext);
}
sub delete_data
{
my($m) = @_;
$m->delete('sel.first','sel.last') # Remove Selected text
if($m->selectionPresent()); # if Selection Present
}
sub popups
{
my($w) = @_ ;
my $mnu = $mw->Menu(-menuitems => [
["command" =>'Copy' , -command => sub{ ©_data($w);} ],
'',
["command" => 'Paste' , -command => sub {&paste_data($w) ;} ],
'',
["command" => 'Delete' , -command => sub {&delete_data($w) ;} ],
],-tearoff=>0);
$mnu->Popup(-popover=>'cursor',-popanchor=>"nw");
}
Regards,
Nagandla.
.
- Follow-Ups:
- Re: Popup Menu problem while copy and paste..
- From: Ch Lamprecht
- Re: Popup Menu problem while copy and paste..
- Prev by Date: Re: Question about reading a directory
- Next by Date: Re: Popup Menu problem while copy and paste..
- Previous by thread: How to avoid default keyboard bindings..
- Next by thread: Re: Popup Menu problem while copy and paste..
- Index(es):
Loading