Discussion:
[Gtk-sharp-list] Textview keypress event problem
Atis
2009-04-09 09:16:14 UTC
Permalink
Hello all,
I would like to use the keypress event (C#) to decide whether the content of a textview widget has changed or not at the exit of an application. If it changed, I ask whether I should save the modification or not. My problem is that the keypress event captures only the Lshift, Rshift, Caps lock keys, but not the regular "letter" and "number" keys.
(this is the function, autogenerated by monodevelop )

protected virtual void OnTxtwMegjegyzesKeyPressEvent (object o, Gtk.KeyPressEventArgs args)
{
valtozas="1";
}

It should be fired up when any key pressed with the focus on the textview widget.
Any help please? Thanks, Ati

________________________________________________________
AEG – ELECTROLUX háztartási gépek NAPI AKCIÓS ÁRON ITT!
MOSÓGÉPEK – mosogatógépek – hûtõk – sütõ + fõzõlap szettek ORSZÁGOS házhozszállítással!
VIDEÓ termékbemutatóinkkal OTTHONODBA viszi a bolti vásárlás élményét az AEGshop.hu!
http://ad.adverticum.net/b/cl,1,6022,322332,397458/click.prm
Chris Howie
2009-05-20 16:08:06 UTC
Permalink
You would need to annotate that method with [GLib.ConnectBefore] for
this to work.
Post by Atis
Hello all,
I would like to use the keypress event  (C#) to decide whether the content
of a textview widget has changed or not at the exit of an application. If it
changed, I ask whether I should save the modification or not. My problem is
that the keypress event captures only the Lshift, Rshift, Caps lock keys,
but not the regular "letter" and "number" keys.
(this is the function, autogenerated by monodevelop )
protected virtual void OnTxtwMegjegyzesKeyPressEvent (object o, Gtk.KeyPressEventArgs args)
        {
            valtozas="1";
        }
It should be fired up when any key pressed with the focus on the textview widget.
Any help please? Thanks, Ati
________________________________________________________
AEG – ELECTROLUX háztartási gépek NAPI AKCIÓS ÁRON ITT!
MOSÓGÉPEK – mosogatógépek – hűtők – sütő + főzőlap szettek ORSZÁGOS
házhozszállítással!
VIDEÓ termékbemutatóinkkal OTTHONODBA viszi a bolti vásárlás élményét az
AEGshop.hu!
_______________________________________________
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
--
Chris Howie
http://www.chrishowie.com
http://en.wikipedia.org/wiki/User:Crazycomputers
Michael Hutchinson
2009-05-22 04:11:23 UTC
Permalink
Post by Atis
I would like to use the keypress event  (C#) to decide whether the content
of a textview widget has changed or not at the exit of an application. If it
changed, I ask whether I should save the modification or not. My problem is
that the keypress event captures only the Lshift, Rshift, Caps lock keys,
but not the regular "letter" and "number" keys.
Why not use the TextView's buffer's Modified flag?
http://www.go-mono.com/docs/index.aspx?link=P:Gtk.TextBuffer.Modified

(The reason you can't capture all the keystroke events is that the
textview is subscribed to the key events itself in order to capture
key input, and when it "consumes" keystrokes it prevents the event
from propagating to other handlers. You can work around this, as Chris
said, by putting the [GLib.ConnectBefore] on your handler, which
causes GTK# to insert your handler *before* the widget's own handler).
--
Michael Hutchinson
http://mjhutchinson.com
bdubu
2009-07-19 17:39:56 UTC
Permalink
Post by Michael Hutchinson
(The reason you can't capture all the keystroke events is that the
textview is subscribed to the key events itself in order to capture
key input, and when it "consumes" keystrokes it prevents the event
from propagating to other handlers. You can work around this, as Chris
said, by putting the [GLib.ConnectBefore] on your handler, which
causes GTK# to insert your handler *before* the widget's own handler).
Unless I've stumbled on some kind of bug or am doing something incorrectly,
etc. it appears that you can in fact capture the TextView's keystroke event
like the OP wanted (without use of [GLib.ConnectBefore]). Instead of using
the KeyPressEvent you have to use the KeyReleaseEvent. That said, I agree
that the TextView buffer's Modified flag is the way to go in the OP's
case...
--
View this message in context: http://www.nabble.com/Textview-keypress-event-problem-tp22967307p24559111.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.
Loading...