【问题标题】:Enabling key event handling for gtk# (Mono)为 gtk#(单声道)启用键事件处理
【发布时间】:2014-01-30 22:46:50
【问题描述】:

以下代码在用户按键时不会触发KeyPress事件...

public class FooWidget : DrawingArea {

    public FooWidget () {
        this.AddEvents ((int)Gdk.EventMask.KeyPressMask);
    }

    [GLib.ConnectBefore]
    protected override bool OnKeyPressEvent (Gdk.EventKey evnt) {
        Console.WriteLine (evnt);
        return base.OnKeyPressEvent (evnt);
    }

}

出了什么问题?

【问题讨论】:

    标签: mono keyboard gtk keypress gtk#


    【解决方案1】:

    自己找到的:

    您需要能够专注于Widget

    this.CanFocus = true;
    this.Focus();
    

    【讨论】:

      猜你喜欢
      • 2022-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-17
      • 2014-04-23
      相关资源
      最近更新 更多