Re: Gtk2::Entry catching a keypress?




On Jul 30, 2008, at 10:36 AM, zentara wrote:

$entry->signal_connect ('key-press-event' => sub {

To expound a bit. this is a standard Gtk2::Widget signal, available for all widgets, but it works only on widgets which have a GdkWindow. A widget must have a GdkWindow in order to receive events (because the GdkWindow corresponds to the XWindow, which is where the X events actually go). There are lots of subtleties there and i wish i could relate how i learned them, but i don't remember. :-/

$widget->no_window returns true for widgets which have no GdkWindow, such as Label or Image.

Also, even on a windowed widget, the window isn't created until the widget is "realized" (that is, the realize signal is emitted). In layman's terms, the key events won't show up until the widget it on the screen.


--
If the monkey could type one keystroke every nanosecond, the expected waiting time until the monkey types out Hamlet is so long that the estimated age of the universe is insignificant by comparison ... this is not a practical method for writing plays.
  -- Gian-Carlo Rota





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