C # / MonoDevelop: GTK MessageDialogs requires a double click to close - why?

I am a novice programmer who wrote a program in MonoDevelop in C # and have a badge with my gtk MessageDialogs.

The close button on GTK message dialog boxes requires a double click to close them. The closing button on the dialogue of his "I" works fine. Can someone please tell me how can I fix this below, this is the code:

  if (fchDestination.CurrentFolder == fchTarget.CurrentFolder) {
   MessageDialog msdSame = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Close, "Destination directory cannot be the same as the target directory");
   msdSame.Title="Error";
   if ((ResponseType) msdSame.Run() == ResponseType.Close) {
    msdSame.Destroy();
   }
   return;
  }

  if (fchTarget.CurrentFolder.StartsWith(fchDestination.CurrentFolder)) {
   MessageDialog msdContains = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Close, "error");
   msdContains.Title="Error";
   if ((ResponseType) msdContains.Run() == ResponseType.Close) {
    msdContains.Destroy();
   }
   return;
  }
+3
source share
3 answers

, " ", CLOSE, DELETE_EVENT. destroy . , ( run), .

, ResponseType.DeleteEvent.

Update:

:

MessageDialog msdSame = ...
...
ResponseType response = (ResponseType) msdSame.Run();
if (response == ResponseType.Close || response == ResponseType.DeleteEvent) {
  msdSame.Destroy();
}

, ptomato, , , : "".

MessageDialog msdSame = ...
...
msdSame.Run();
msdSame.Destroy();
+4

, , , msgbox, , , , .

0

:

using System;
using Gtk; 
namespace Visitors.Clases.MessageBox
{   
    public static class MessageBox 
    {
        public static Gtk.ResponseType Show(Gtk.Window window, Gtk.DialogFlags dialogflags, MessageType msgType,ButtonsType btnType,string Message,String caption)
        {

            MessageDialog md = new MessageDialog (window,dialogflags,msgType,btnType, Message);
            md.Title = caption;
            ResponseType tp = (Gtk.ResponseType)md.Run();       
            md.Destroy(); 
            return tp;
        }
    }
}

:

ResponseType result = MessageBox.Show(this,DialogFlags.Modal,MessageType.Error,ButtonsType.Ok,Error,"ERROR");
if (result == Gtk.ResponseType.Yes)
{
    MessageBox.Show (this, DialogFlags.Modal, MessageType.Other,ButtonsType.Ok, "YES", "EJEMPLO");
}
else
{
    MessageBox.Show (this, DialogFlags.Modal, MessageType.Other,ButtonsType.Ok, "NO", "EJEMPLO");
}
0

Source: https://habr.com/ru/post/1740003/


All Articles