gtktext/signal question




Hi!

I'm working on an editor widget (subclass of gtktext for source code
editing) with syntax highlighting.

To do the highlighting I have to keep track of the state I am in at
any given point (point within comment, string or other).

So what I would like is to catch the key_press event and change the
state according to the key pressed. I don't want to do all the work
of calculating the points movement, which is already done in the text
widget, so I want my function to be called after the text widgets
event handler.

So in my widgets _init() i connect

  gtk_signal_connect_after (GTK_OBJECT (editor), "key_press_event",
			    GTK_SIGNAL_FUNC (gtk_editor_key_press),
			    NULL);

This works fine as long as I'm only typing in text, but when I start
moving the point around (key up, key down, etc.) it behaves a little
different than I would expect.

The first of such a keystroke makes the widget leave focus and
responds to the event, while the next returns focus.  Why is a mystery
to me. Perhaps I'm missing something about the signal handling. Do I
need to do something to 'terminate' the signal calls before the
changes take place? Or, is it something with the text widget?

This problem doesn't show if I use gtk_signal_connect (not
_after). But that's not really helping.

Any suggestions?

/mailund

-- 
| Thomas Mailund                  |            Office B2.18 at DAIMI |
| Ny Munkegade 62 3. tv.          |      Email: mailund@daimi.aau.dk |
| 8000 Aarhus, Denmark            | http://www.daimi.aau.dk/~mailund |
| Phone (+45) 21 45 13 95         |         Phone: (+45) 89 42 32 80 |



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