Hi
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;
            if(dict.ContainsKey(key))
            {
            this.Buffer.InsertInteractiveAtCursor(dict[key].ToString(),
true);
            }
            else
            {
                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?
Regards
-- 
Muhammad Shakir Aziz محمد شاکر عزیز
_______________________________________________
Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Reply via email to