enter in entry fields; modal windows



Hi everybody,

I'm using this code to run code when someone presses enter in a entry widget:

      $entry->signal_connect("key_press_event" => sub {
        use Gtk2::Gdk::Keysyms;
        my $key = {reverse %Gtk2::Gdk::Keysyms}->{$_[1]->keyval};
        if($key =~ m/^(KP_Enter)|(Return)$/) {
          $button->clicked;
        }
      } );

In the documentation I've found activates_default:
âactivates-defaultâ (boolean : readable / writable / private)
           Whether to activate the default widget (such as the default button     
           in a dialog) when Enter is pressed

However, I don't understand how to use it. How can I define the button that is 
activated?
I know there is more than one way to do it, but in this partitcular case: Is 
there a more elegant way to do it?

Another problem: I have two windows and one window is modal. How can I prevent 
that the window that is not modal gets the focus. At the moment all widgets 
are not sensitive, but the window can still get the focus.

Thank you.

--Michael



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]