【问题标题】:MessageBox In GTK Never ShownGTK 中的 MessageBox 从未显示
【发布时间】:2019-08-22 22:23:31
【问题描述】:

我在 OSX 上使用 VS Code 并试图在我的按钮按下事件上向用户显示一个对话框。下面的代码是我所拥有的,但是当按下按钮时,对话框永远不会显示。

    public static void Main(string[] args)
    {
        Application.Init();

        MainWindow win = new MainWindow();

        Button btnClick = new Button("Button");
        win.Add(btnClick);

        btnClick.ButtonPressEvent += new ButtonPressEventHandler(ButtonPressHandler);
        btnClick.Visible = true;
        win.Show();
        Application.Run();

    }

    private static void ButtonPressHandler(object obj, ButtonPressEventArgs args)
    {
        MessageDialog md = new MessageDialog(null, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Ok, "You pressed the button!");
        md.Run();
        md.Destroy();
    }

【问题讨论】:

  • 最小的工作示例?

标签: c# gtk


【解决方案1】:

我认为您想要 btnClick.Clicked 而不是 btnClick.ButtonPressEvent。甚至似乎没有 ButtonPressEvent 成员。见http://docs.go-mono.com/?link=T%3aGtk.Button

【讨论】:

    猜你喜欢
    • 2010-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多