$txtBox->tagRanges('sel'); returns begin/end coordinates of selection in <x,y> 2D format and if I extract data from widget via get() method it will be 1D string. Is there simple method to convert coordinates to 1D?
$txtBox->tagRanges('sel'); doesn't return 2D coordinates, it returns the line.column of the selected text start and end point(s). If you get() the text between those endpoints, you will have the selected text.
my @ranges = $txtBox->tagRanges('sel'); my $text = $txtBox->get(@ranges[0,1]);
When I select anything, I get error 'Tk::Error: wrong # args: should be ".frame1.text get index1 ?index2 ...?" at C:/Perl/lib/Tk.pm line 252'
Because you are not giving the get() method any indicies to work with. Try:
if(@r) { my $str = $txtBox->get(@r);
Note that @r may have more than two coordinates. You may need to test and allow for them.
...if I use 'delete', 'insert' (and other Tk::Entry commands)...
Be aware that Tk::Entry methods != Tk::Text methods for the most part. There are many similarities, but many differences too. Do you want to do this with a Tk::Text box or a Tk::Entry? It would probably be easier with the Tk::Entry, it doesn't already have a defined action bound to the Return key. Tk::Text does, so you'll have to try to figure out what action the user meant when they hit Return. Not impossible, but a larger can of worms than I would want to open.
In reply to Re: Tk::Entry selection problem
by thundergnat
in thread Tk::Entry selection problem
by grizzley
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |