Re: DialobBox, Text widget and newlines



Wes Barris <noway@xxxxxxxxx> writes in article %:
> Hi,
>
> I have a DialogBox containing a Text widget. I would like to be able
> to type text (including newline or return characters) into the Text
> area of this DialogBox. The problem is that whenever I press the "Enter"
> key to insert a carriage return in the text that I am typing, one of
> the DialogBox buttons "sees" the carriage return and the DialogBox is
> removed. I don't want the DialogBox to be removed until I "click" on
> one of its buttons. How can I do this? Here is some sample code:
>
> my $dialogBox = $main->DialogBox(-title=>$appname, -buttons=>['Ok', 'Cancel']);
> my $text = $dialogBox->add('Text', -width=>30, -height=>10, -wrap=>'word',
> -takefocus=>1)->grid(-row=>3, -column=>1, -sticky=>'ew');
> my $response = $dialogBox->Show;

use strict;
use Tk;
use Tk::DialogBox;

my $main = tkinit;
my $dialogBox = $main->DialogBox(-buttons=>['Ok', 'Cancel']);
my $text = $dialogBox->add('Text',
-width => 30, -height => 10, -wrap => 'word',
)->grid(-row=>3, -column=>1, -sticky=>'ew');
$dialogBox->configure(-focus => $text);
$dialogBox->bind('<Return>' => undef);
my $response = $dialogBox->Show;

--
Go to http://MarcDashevsky.com to send me e-mail.
(Reunion -- http://ClassicalHigh70.com)
.