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

I have a Tk DialogBox that contains a Text box subwidget in its top frame. There are "OK' and 'cancel' buttons in the bottom frame. I want to be able to allow the user to press <Enter> when the focus is in the Textbox and add a new line of text. Instead what is happening is that the <Enter> key is causing the DialogBox button binding to be invoked, and it behaves as if i was pressing the OK button. Any way to get my textbox behavior back in this circumstance?

Replies are listed 'Best First'.
Re: Tk DialogBox Enter key behavior
by lamprecht (Friar) on Jun 17, 2010 at 23:07 UTC
    Hi,

    remove the Dialogs <Return> binding:

    use strict; use warnings; use Tk; my $mw = tkinit; my $d = $mw->DialogBox(); $d->add('Text')->pack; $d->bind('<Return>',''); $d->Show;

    Cheers, Christoph