Re: focus, and intercepting arrow keys



On Mar 22, muppet said:

I have Notebook and Button widgets, but I'd really like to intercept the pressing of arrow keys and have them affect an entirely different widget. Where should I set up the signal handler, and how can I prevent the arrow keys from "falling through" my key_press handler to the other widgets?

- declare public functions on my image display widget to do zooming scrolling.
- connect to the key-press-event of the toplevel window in which the widget is packed - in that handler, call the appropriate functions on the widget in response to the arrow keys and +/- keys. - if i handled the event, return TRUE to stop event propagation. otherwise, return FALSE to let the default handling occur.

arguably, a more correct way to do it would've been to make the widget itself focusable, and then set up the key handling only in that widget, but i had trouble with that (and it was long ago so i don't remember why).

Ah HA. Thank you. I wasn't setting the handler for the toplevel, I was doing it for the container holding the widget. I was doing everything else right.

--
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %    -- Meister Eckhart



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