Newbie: Paste selection in Hlist using mouse 
Author Message
 Newbie: Paste selection in Hlist using mouse

Hi,

I have an Hlist window with 3 columns.
How do I paste with a mouse what I selected?

Actually, I would love to be able to paste several entries (just the value
in the first column) at once, to utilize the:
         -selectmode => 'extended' parameter.

I tried many ways including using data and info, which print it to STDOUT,
but could not get it to paste it with the mouse.

Thanks,

Sefi.

Here is a piece of the code:
-----------------------------
    $top = new MainWindow;

    $hlist = $top->Scrolled("HList",
                            -header => 1,
                            -columns => 3,
                            -scrollbars => 'osoe',
                            -width => 80,
                            -selectmode => 'extended',
                            -selectbackground => 'SeaGreen3',
                           )->pack(-expand => 1, -fill => 'both');
    $hlist->columnWidth(0);
    $hlist->columnWidth(1);
    $hlist->columnWidth(2);
    $hlist->header('create', 0, -text => 'Parameter');
    $hlist->header('create', 1, -text => 'Range & Constraints');
    $hlist->header('create', 2, -text => 'Default');

    while ($selected_line = <MAC>) {
      if ($selected_line =~
          /${selection}\s*(\w+)?\s{5,}(.*?)\s{5,}(.*)?\s{5,}/) {
      ($parameter,$range,$default) = ($1,$2,$3);
      $hlist->add($parameter, -text => "stam", -data => [$parameter]);
      $hlist->itemCreate($parameter, 0, -text => $parameter);
      $hlist->itemCreate($parameter, 1, -text => $range);
      $hlist->itemCreate($parameter, 2, -text => $default);
    }
  }
       close (MAC);
  }



Sun, 28 Dec 2003 04:35:04 GMT  
 Newbie: Paste selection in Hlist using mouse

Quote:

> Hi,

> I have an Hlist window with 3 columns.
> How do I paste with a mouse what I selected?

> Actually, I would love to be able to paste several entries (just the value
> in the first column) at once, to utilize the:
>          -selectmode => 'extended' parameter.

> I tried many ways including using data and info, which print it to STDOUT,
> but could not get it to paste it with the mouse.

Yep, you can't.  I never tried to do what I am suggesting, but what
*might* work is to bind the mouse click to a subroutine that would
update the x-paste property.  In this case, you could do just about
anything you could code (like changing what is pasted to some
complicated formatted statement).

But the bottom line is that there is no direct way to do what you want,
the way Hlist is defined, it simply precludes it.

Quote:

> Thanks,

> Sefi.

> Here is a piece of the code:
> -----------------------------
>     $top = new MainWindow;

>     $hlist = $top->Scrolled("HList",
>                             -header => 1,
>                             -columns => 3,
>                             -scrollbars => 'osoe',
>                             -width => 80,
>                             -selectmode => 'extended',
>                             -selectbackground => 'SeaGreen3',
>                            )->pack(-expand => 1, -fill => 'both');
>     $hlist->columnWidth(0);
>     $hlist->columnWidth(1);
>     $hlist->columnWidth(2);
>     $hlist->header('create', 0, -text => 'Parameter');
>     $hlist->header('create', 1, -text => 'Range & Constraints');
>     $hlist->header('create', 2, -text => 'Default');

>     while ($selected_line = <MAC>) {
>       if ($selected_line =~
>           /${selection}\s*(\w+)?\s{5,}(.*?)\s{5,}(.*)?\s{5,}/) {
>       ($parameter,$range,$default) = ($1,$2,$3);
>       $hlist->add($parameter, -text => "stam", -data => [$parameter]);
>       $hlist->itemCreate($parameter, 0, -text => $parameter);
>       $hlist->itemCreate($parameter, 1, -text => $range);
>       $hlist->itemCreate($parameter, 2, -text => $default);
>     }
>   }
>        close (MAC);
>   }



Sun, 28 Dec 2003 05:44:12 GMT  
 Newbie: Paste selection in Hlist using mouse

Quote:


> > Hi,

> > I have an Hlist window with 3 columns.
> > How do I paste with a mouse what I selected?

> > Actually, I would love to be able to paste several entries (just the value
> > in the first column) at once, to utilize the:
> >          -selectmode => 'extended' parameter.

> > I tried many ways including using data and info, which print it to STDOUT,
> > but could not get it to paste it with the mouse.

> Yep, you can't.  I never tried to do what I am suggesting, but what
> *might* work is to bind the mouse click to a subroutine that would
> update the x-paste property.  In this case, you could do just about
> anything you could code (like changing what is pasted to some
> complicated formatted statement).

> But the bottom line is that there is no direct way to do what you want,
> the way Hlist is defined, it simply precludes it.

After doing a bit more research, I believe you might want to try the
functions clipboardAppend and clipboardClear which have the effect of
modifying the x-paste or the clipboard.

How this would work is something like:

$hlist->bind('<B3>',\&updateClip); # bind right mouse click

sub updateClip {
  my $w=shift;
  my $col1 = $w-># get column 1
  my $col2 = $w-># get column 2
  my $col3 = $w-># get column 3
  $hlist->clipboardClear;
  $hlist->clipboardAppend("column 1: $col1 column2: $col2 column3:
$col3");

Quote:
}

"Your mileage may vary..."

- Show quoted text -

Quote:

> > Thanks,

> > Sefi.

> > Here is a piece of the code:
> > -----------------------------
> >     $top = new MainWindow;

> >     $hlist = $top->Scrolled("HList",
> >                             -header => 1,
> >                             -columns => 3,
> >                             -scrollbars => 'osoe',
> >                             -width => 80,
> >                             -selectmode => 'extended',
> >                             -selectbackground => 'SeaGreen3',
> >                            )->pack(-expand => 1, -fill => 'both');
> >     $hlist->columnWidth(0);
> >     $hlist->columnWidth(1);
> >     $hlist->columnWidth(2);
> >     $hlist->header('create', 0, -text => 'Parameter');
> >     $hlist->header('create', 1, -text => 'Range & Constraints');
> >     $hlist->header('create', 2, -text => 'Default');

> >     while ($selected_line = <MAC>) {
> >       if ($selected_line =~
> >           /${selection}\s*(\w+)?\s{5,}(.*?)\s{5,}(.*)?\s{5,}/) {
> >       ($parameter,$range,$default) = ($1,$2,$3);
> >       $hlist->add($parameter, -text => "stam", -data => [$parameter]);
> >       $hlist->itemCreate($parameter, 0, -text => $parameter);
> >       $hlist->itemCreate($parameter, 1, -text => $range);
> >       $hlist->itemCreate($parameter, 2, -text => $default);
> >     }
> >   }
> >        close (MAC);
> >   }



Sun, 28 Dec 2003 08:05:03 GMT  
 Newbie: Paste selection in Hlist using mouse

Quote:

> Hi,

> I have an Hlist window with 3 columns.
> How do I paste with a mouse what I selected?

> Actually, I would love to be able to paste several entries (just the value
> in the first column) at once, to utilize the:
>          -selectmode => 'extended' parameter.

> I tried many ways including using data and info, which print it to STDOUT,
> but could not get it to paste it with the mouse.

> Thanks,

> Sefi.

> Here is a piece of the code:
> -----------------------------
>     $top = new MainWindow;

>     $hlist = $top->Scrolled("HList",
>                             -header => 1,
>                             -columns => 3,
>                             -scrollbars => 'osoe',
>                             -width => 80,
>                             -selectmode => 'extended',
>                             -selectbackground => 'SeaGreen3',

Just add
        -exportselection => 1

Regards,
        Slaven

--

    tksm - Perl/Tk program for searching and replacing in multiple files
    http://ptktools.sourceforge.net/#tksm



Sun, 28 Dec 2003 15:27:36 GMT  
 Newbie: Paste selection in Hlist using mouse

Quote:


> > Hi,

> > I have an Hlist window with 3 columns.
> > How do I paste with a mouse what I selected?

> > Actually, I would love to be able to paste several entries (just the value
> > in the first column) at once, to utilize the:
> >          -selectmode => 'extended' parameter.

> > I tried many ways including using data and info, which print it to STDOUT,
> > but could not get it to paste it with the mouse.

> > Thanks,

> > Sefi.

> > Here is a piece of the code:
> > -----------------------------
> >     $top = new MainWindow;

> >     $hlist = $top->Scrolled("HList",
> >                             -header => 1,
> >                             -columns => 3,
> >                             -scrollbars => 'osoe',
> >                             -width => 80,
> >                             -selectmode => 'extended',
> >                             -selectbackground => 'SeaGreen3',
> Just add
>         -exportselection => 1

This *would* work if you only had a single column.  The multiple column
nature means that you cannot both export the selection *and* select more
than one thing (i.e. more than one column.)

- Show quoted text -

Quote:

> Regards,
>         Slaven

> --

>     tksm - Perl/Tk program for searching and replacing in multiple files
>     http://ptktools.sourceforge.net/#tksm



Mon, 29 Dec 2003 00:47:42 GMT  
 Newbie: Paste selection in Hlist using mouse

[...]

Quote:

> > > Here is a piece of the code:
> > > -----------------------------
> > >     $top = new MainWindow;

> > >     $hlist = $top->Scrolled("HList",
> > >                             -header => 1,
> > >                             -columns => 3,
> > >                             -scrollbars => 'osoe',
> > >                             -width => 80,
> > >                             -selectmode => 'extended',
> > >                             -selectbackground => 'SeaGreen3',
> > Just add
> >         -exportselection => 1

> This *would* work if you only had a single column.  The multiple column
> nature means that you cannot both export the selection *and* select more
> than one thing (i.e. more than one column.)

It works, at least with X11. Multiple columns are separated by tabs.

Regards,
        Slaven

--

    tkrevdiff - graphical display of diffs between revisions (RCS or CVS)
    http://ptktools.sourceforge.net/#tkrevdiff



Mon, 29 Dec 2003 03:54:22 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Paste selection from Hlist in another Xterm.

2. HList selection with right mouse button?

3. Binding a mouse wheel to an HList

4. left mouse click on HList throws messages when empty

5. Getting all selection from hlist and tar them?

6. help with Perl TK HList and selection

7. HList - how to undo selection

8. HList: Drag-n-Drop, changing selections

9. cut and paste using perl script

10. Copy/Paste using Perl?

11. Usernames in chat using TCP/IP Source Pasted

12. using perl scripts to paste ads on remote servers

 

 
Powered by phpBB® Forum Software