【问题标题】:Getting the mouse coordinates when ButtonPressEvent occursButtonPressEvent 发生时获取鼠标坐标
【发布时间】:2010-05-26 15:56:10
【问题描述】:

我在一个事件框中封装了一个绘图区域,这样我就可以用这个函数捕捉鼠标点击:

protected virtual void OnEventbox1ButtonPressEvent (object o, Gtk.ButtonPressEventArgs args)
{
    Console.WriteLine("Clicked!");
}

我怎样才能知道鼠标点击的位置

【问题讨论】:

    标签: c# mono gtk#


    【解决方案1】:

    通常该信息存储在args 对象中。我对 Gtk 不是很熟悉,但我想它与 .Net 点击事件的实现并没有太大的不同。

    【讨论】:

    • 你似乎是对的......我发现了四个有助于解决问题的属性:Console.WriteLine("Location relative to the current widget (" + args.Event.X + ", " + args.Event.Y + ")");Console.WriteLine("Location relative to the computer screen (" + args.Event.XRoot + ", " + args.Event.YRoot + ")");
    猜你喜欢
    • 1970-01-01
    • 2010-12-03
    • 1970-01-01
    • 2010-09-09
    • 1970-01-01
    • 2021-01-05
    • 1970-01-01
    • 2015-11-03
    • 2011-04-11
    相关资源
    最近更新 更多