Re: Gtk2::DrawingArea



On 08:30 Tue 05 Feb     , muppet wrote:

By virtue of adding the key-press-event mask to the widget's event set,
the drawing area is set up to monitor key-press-event, but is not allowed to
take keyboard focus until you enable it.  You need to do

  $draw->can_focus (TRUE);


Now that works!

Ah! 

Now I see why it worked in the histogram.pl example in the Gtk2-1.153/examples.

You set it there as well. I did not think/know about focus.

I just sat down and read about focus in the Havoc Pennington GTK+/Gnome application development book.

Now, this was really good to know. 

I will have to think about focus for a bit.

Q1. Is the can_focus(TRUE) (as opposed to set_focus)
 typically needed only for widgets like DrawingArea
that don't have a 'place' to put text? I guess I can always
try the function  if I find I need it :).

***********************


I notice  that I can capture modifier masks for the 
GdkEventButton directly using the state member
so I can do 

 if ($state >= ["button2-mask","control-mask" ])

while doing a pointer-motion, in the 
sub motion_notify_event {
}.


This works for Control/Alt/Caps-Lock/Shift modifiers of a pointer-motion
or a button-press-event. 

On the other hand I would have to use the 
signal from a key-press or key-release event  (together with can_focus),
if I wanted to capture more obscure key  presses like "A" together
with pointer motion.

Mitchell
 

(Dear muppet - sorry I sent the original letters to you and not to the list. 
I hit r instead of L in mutt :(. 



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