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

I would like to create a text entry widget that allows you to cut and paste a block of text into it and then you could highlight different sections and click a button to assign the highlighted text to specfic variables for export to a spreadsheet. I think I got the spreadsheet part nailed, but the mouse selection is more difficult. To be honest, I have no idea how to do it. Am I missing something really obvious? Any help is humbly appreciated. Most penitently, Vic
  • Comment on Assigning variables with mouse highlighting

Replies are listed 'Best First'.
Re: Assigning variables with mouse highlighting
by Errto (Vicar) on Feb 03, 2005 at 22:58 UTC
    Please let us know what module you are using. Tk, GTK+, Win32::GUI, something else? In Tk you can do this by creating a tag on your Text widget using the "bind" method, to call a particular subroutine on double-click, and use the getSelected method to obtain the current selection at that point.
    my $mw = MainWindow->new; my $txt = $mw->Text(-height => 5, -width => 40); $txt->bind('<Double-Button-1>', sub { local $\ = "\n"; print $txt +->getSelected}); $txt->pack;
      I am using TK.
Re: Assigning variables with mouse highlighting
by tilly (Archbishop) on Feb 04, 2005 at 07:00 UTC
    An alternate interface that might be easier, have a place on your form where you paste in a block of text, select a dropdown and then hit a button to paste that text to the variable selected in your dropdown.

    A nice thing about this approach is that all of the operations are going to be familiar to people who've never used your application. While "highlight this and click, then highlight that and click..." is going to be unusual enough to throw a lot of users.