GtkD functions not properly displaying menus

72 Views Asked by At

I am experimenting with the GtkD UI library (Gtk for the D language) and have created a simple window with a menu. The code for the menu is below:

class TopView : Box
{
   MainMenu theBar;

    this()
    {
        super(Orientation.VERTICAL,10);
        theBar = new MainMenu();
    
        packStart(theBar,false,false,0);
   }
}

class MainMenu : MenuBar
{
    private MenuItem fileItem;
    private FileMenu fileMenu;

    this()
    {
        super();

        fileItem = new MenuItem("File");
        fileMenu = new FileMenu();
 
        fileItem.setSubmenu(fileMenu);
        append(fileItem);
    }
}

class FileMenu : Menu
{
    private MenuItem exitItem;

    this()
    {
        super();

        exitItem = new MenuItem("Exit");
        exitItem.addOnActivate(&closeApp);
        append(exitItem);
    }

    private void closeApp(MenuItem anItem)
    {
        Main.quit();
    }
}

The window is displayed without problems and the menubar appears with the "File" item, but when I click on the "File" item, the menu with "Exit" does not appear under it. Regardless of where the main window is positioned, the menu with Exit appears at screen position 0,0!

In other words, the menu appears at the top left corner of my computer screen whenever I click on "File".

Have I found a bug in the Gtk implementation? I am using Version 3.9.0 of the GtkD library, and Version 3.24.8 of the Gtk runtime. Or am I missing something in my code? How do I get the menu to display correctly?

1

There are 1 best solutions below

0
On

I found out why the menus display incorrectly:

This is apparently a bug in the library for Windows. I copied the same code to a Linux environment, compiled and ran it. The menu displayed correctly in its proper position. On Windows, this code puts the menu on the upper left corner (position 0,0) of the screen.

I have found where to report this bug. Hopefully, the folks who maintain GtkD and Gtk for Windows will be able to fix it relatively quickly...