[Gtk-sharp-list] Subclassing a textview cannot control ControlMask key event
true.friend2004 at gmail.com
Mon Aug 25 05:26:14 EDT 2008
I am trying to subclass a textview to write custom characters. Here is the
sample code which I am using in "protected override OnKeyPress(EventArgs
evnt)" method in derived class.
protected override bool OnKeyPressEvent (EventKey evnt)
Dictionary<char, char> dict = new Dictionary<char,char>();
dict['`'] = 'ٍ';
dict['1'] = '1';
dict['2'] = '2';
dict['3'] = '3';
dict['4'] = '4';
if(evnt.State != ModifierType.ControlMask)
char key = (char)evnt.Key;
this.Editable = false;
this.Editable = true;
return base.OnKeyPressEvent (evnt);
I want to write only when Ctrl key is not pressed when it is pressed the
event should be the default one, I've tried to do so but evnt.State !=
ModifierType.ControlMask is not working. The output on console.Writeline is
also given here. Normal key press is Mod2Mask but ctrl key press plus any
other key press is ControlMask, Mod2Mask two in same line are written.
Interesting is this it is accepting ControlMask (input) but allowing to
write the key as well (the hacked evenet handler is processed even).
Any ideas about it? I am missing something or something else involved here?
Muhammad Shakir Aziz محمد شاکر عزیز
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Gtk-sharp-list