How to handle focus_in_events ?



There is probably a much better solution to this, but i simply do not see
it. The problem: my application has both a drawing area (where line drawing
and text are possible in separate drawing modes) and a GtkEntry
widget where text can be prepared for insertion into the drawing. To
complicate matters, inserting of simple texts is also possible in line
drawing mode (using single key shortcuts via a key_press_event handler).

The immediate problem is that the shortcuts interfere with the GtkEntry,
when the user forgets to switch from line drawing to text mode before he
starts entering text in the widget. (The characters typed in the GtkEntry
are processed as shortcuts, inserting their corresponding phrases into the
drawing).

What i would like to do now is to have my program switch to "text insertion"
mode when the user moves the cursor from the drawing area to the text entry
widget. Judging from the headers, the "focus_in_event" appears promising, 
so i tried:
gtk_signal_connect(GTK_OBJECT (textbox), "focus_in_event",   
                   GTK_SIGNAL_FUNC (Change_Text),GINT_TO_POINTER(0) );
where textbox is my GtkEntry widget, and Change_Text a callback function
that switches to centered, left- or right-justified text drawing depending
on the value that is supplied via the user_data pointer:
Change_Text (GtkWidget * mainw, gpointer user_data)
{textdir=GPOINTER_TO_INT(user_data); /*case 0: case -1: case -2:*/}

Unfortunately this does not work - textdir is some huge junk number 
instead of the expected int, whereas the same code works fine for
connecting "clicked" signal of the individual "centered-text",etc. buttons.

What am i missing here ??
Martin
-- 
Dr. Martin Kroeker, daVeg GmbH Darmstadt  CAD/CAM/CAQ  mk daveg com
                      Precision Powered by Penguins




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