Thanks for your replies. Unfortunately, for reasons beyond my control, Win32::GUI is not available for me to use. What I did was take the advice of both anonymous monk and Khen1950fx, and modify the Perl module MListbox.pm:
First I added Control-c capabilities. Note that I need to account for lower case 'c' and upper case 'C', for when capslock is turned on:
sub ClassInit {
my ($class,$mw) = @_;
$mw->bind($class,'<Configure>',['_yscrollCallback']);
$mw->bind($class,'<Down>',['_upDown',1]);
$mw->bind($class,'<Up>', ['_upDown',-1]);
$mw->bind($class,'<Shift-Up>', ['_extendUpDown',-1]);
$mw->bind($class,'<Shift-Down>',['_extendUpDown',1]);
$mw->bind($class,'<Control-Home>','_cntrlHome');
$mw->bind($class,'<Control-End>','_cntrlEnd');
$mw->bind($class,'<Shift-Control-Home>',['_dataExtend',0]);
$mw->bind($class,'<Shift-Control-End>',['_dataExtend',Ev('index',
+'end')]);
$mw->bind($class,'<Control-slash>','_selectAll');
$mw->bind($class,'<Control-backslash>','_deselectAll');
$mw->bind($class,'<Control-c>','_copyAll');
$mw->bind($class,'<Control-C>','_copyAll');
}
Then I added the following subroutine to the MListbox.pm module. Assuming I was using Khen1950fx's example, if I wanted to be copying column #6 to the clipboard:
sub _copyAll {
my ($w) = @_;
my @sel = $w->curselection;
if (scalar(@sel) > 0){
$w->clipboardClear;
foreach(@sel){
my ($name) = ($w->getRow($_))[6];
$w->clipboardAppend($name);
}
}
}
A bit clunkish, but gets the job done. Any faster ways you can think of to get the stuff copied to the clipboard without going through a loop?
|