Sign up

Submenu Not Responding Until Second Click

I'm just digging into menus. I wrote several tests for a menubar by itself, a single menu with a single item, a single menu with several items, two menus (each with several items, and one with mnemonics attached to some items.

But when I moved on to do a test with submenus, I ran into something odd. Everything compiles and runs normally except that when the window appears and I click on the File menu, a blue line appears under the word File, but the menu doesn't drop. I click it a second time and everything's normal.

I stripped it down to just one menu, one item on the menu which is a submenu, and one item on the submenu. The behaviour is still the same. Here's the boiled down code:

import std.stdio;

import gtk.MainWindow;
import gtk.Box;
import gtk.Main;
import gtk.Menu;
import gtk.MenuBar;
import gtk.MenuItem;
import gtk.Widget;
import gdk.Event;

void main(string[] args)
{
    Main.init(args);

    TestRigWindow testRig = new TestRigWindow();
    
    Main.run();
    
} // main()


class TestRigWindow : MainWindow
{
	string title = "Multiple Menus Example";

	this()
	{
		super(title);
		setDefaultSize(640, 480);
		addOnDestroy(&quitApp);

		AppBox appBox = new AppBox();
		add(appBox);
		
		showAll();
		
	} // this()
	
	
	void quitApp(Widget w)
	{
		// do other exit stuff here if necessary
		
		Main.quit();
		
	} // quitApp()
	
} // TestRigWindow


class AppBox : Box
{
	int padding = 10;
	MyMenuBar menuBar;
	
	this()
	{
		super(Orientation.VERTICAL, padding);
		
		menuBar = new MyMenuBar();
    	packStart(menuBar, false, false, 0);		
		
	} // this()
	
} // class AppBox


class MyMenuBar : MenuBar
{
	string fileHeaderLabel = "File";
	
	FileHeader fileHeader;
	
	this()
	{
		super();
		
		fileHeader = new FileHeader(fileHeaderLabel);
		append(fileHeader);
		
	} // this()

	
} // class MyMenuBar


class FileHeader : MenuItem
{
	FileMenu fileMenu;
	
	// arg: a Menu object
	this(string headerTitle)
	{
		super(headerTitle);
		
		fileMenu = new FileMenu();
		setSubmenu(fileMenu);
		
	} // this()
	
} // class MenuHeader


class FileMenu : Menu
{
	NewFileItem newFileItem;
	
	// arg: an array of items
	this()
	{
		super();
		
		newFileItem = new NewFileItem();
		append(newFileItem);
		
	} // this()
	
	
} // class FileMenu


class NewFileItem : MenuItem
{
	string itemLabel = "New";
	NewFileSubMenu newFileSubMenu;
   
	this()
	{
		super(itemLabel);
		addOnActivate(&doSomething);
		
		newFileSubMenu = new NewFileSubMenu();
		setSubmenu(newFileSubMenu);
		
	} // this()
	
	
	void doSomething(MenuItem mi)
	{
		writeln("New file created.");
		
	} // doSomethingNew()
	
} // class NewFileItem


class NewFileSubMenu : Menu
{
	DFileItem dFileItem;
	
	this()
	{
		super();
		
		dFileItem = new DFileItem();
		append(dFileItem);

	} // this()
	
} // class NewFileSubMenu


class DFileItem : MenuItem
{
	string itemLabel = "D Source File";
   
	this()
	{
		super(itemLabel);
		addOnActivate(&doSomething);
		
	} // this()
	
	
	void doSomething(MenuItem mi)
	{
		writeln("Dialog appears with filter: '*.d'");
		
	} // doSomething()
	
} // class UndoItem

Re: Submenu Not Responding Until Second Click

On Mon, 04 Feb 2019 16:02:08 GMT, Ron Tarrant wrote:

Here's the boiled down code:

Okay, that really wasn't boiled down, but this is:

import std.stdio;

import gtk.MainWindow;
import gtk.Box;
import gtk.Main;
import gtk.Menu;
import gtk.MenuBar;
import gtk.MenuItem;
import gtk.Widget;
import gdk.Event;

void main(string[] args)
{
	Main.init(args);

	MainWindow testRig = new MainWindow("Title");

	Box appBox = new Box(Orientation.VERTICAL, 5);
	testRig.add(appBox);
	
	MenuBar menuBar = new MenuBar();
	appBox.packStart(menuBar, false, false, 0);
	
	MenuItem header = new MenuItem("File");
	menuBar.append(header);
	
	Menu fileMenu = new Menu();
	header.setSubmenu(fileMenu);
	
	MenuItem newFileItem = new MenuItem("New");
	fileMenu.append(newFileItem);
	
	Menu newFileSubmenu = new Menu();
	newFileItem.setSubmenu(newFileSubmenu);

	MenuItem dNewFileItem = new MenuItem("D File");
	newFileSubmenu.append(dNewFileItem);
	
	testRig.showAll();	
	Main.run();
	
} // main()

Also, I'm running this on Windows 10, if that matters.

Re: Submenu Not Responding Until Second Click

On 05-02-2019 11:00, Ron Tarrant wrote:

Also, I'm running this on Windows 10, if that matters.

It looks like it's time to dust of and update the Win10 VM, because i
can't reproduce the issue on linux.

Re: Submenu Not Responding Until Second Click

On Tue, 5 Feb 2019 20:08:58 +0100, Mike Wey wrote:

On 05-02-2019 11:00, Ron Tarrant wrote:

Also, I'm running this on Windows 10, if that matters.

It looks like it's time to dust of and update the Win10 VM, because i
can't reproduce the issue on linux.

Either that or it's time for me to roll up my sleeves and sort out how to run dual external monitors using Xorg and get my laptop running FreeBSD. These hybrid Intel/NVIDIA GPUs are a real pain.

New Info: Turns out of I click on the menu (first time) and hold the mouse button down long enough, the menu does finally appear. This sounds to me like there's an interpreter at work somewhere in the chain. Is that, in effect, what a wrapper does, interpret before passing calls along to the library?

Re: Submenu Not Responding Until Second Click

On 06-02-2019 14:34, Ron Tarrant wrote:

On Tue, 5 Feb 2019 20:08:58 +0100, Mike Wey wrote:

On 05-02-2019 11:00, Ron Tarrant wrote:

Also, I'm running this on Windows 10, if that matters.

It looks like it's time to dust of and update the Win10 VM, because i
can't reproduce the issue on linux.

Either that or it's time for me to roll up my sleeves and sort out how to run dual external monitors using Xorg and get my laptop running FreeBSD. These hybrid Intel/NVIDIA GPUs are a real pain.

New Info: Turns out of I click on the menu (first time) and hold the mouse button down long enough, the menu does finally appear. This sounds to me like there's an interpreter at work somewhere in the chain. Is that, in effect, what a wrapper does, interpret before passing calls along to the library?

It looks like this issue is fixed in gtk 3.24.4, at leased for me i read
on the DLang forums you weren't so lucky.

Re: Submenu Not Responding Until Second Click

On 06-02-2019 19:48, Mike Wey wrote:

On 06-02-2019 14:34, Ron Tarrant wrote:

On Tue, 5 Feb 2019 20:08:58 +0100, Mike Wey wrote:

On 05-02-2019 11:00, Ron Tarrant wrote:

Also, I'm running this on Windows 10, if that matters.

It looks like it's time to dust of and update the Win10 VM, because i
can't reproduce the issue on linux.

Either that or it's time for me to roll up my sleeves and sort out how
to run dual external monitors using Xorg and get my laptop running
FreeBSD. These hybrid Intel/NVIDIA GPUs are a real pain.

New Info: Turns out of I click on the menu (first time) and hold the
mouse button down long enough, the menu does finally appear. This
sounds to me like there's an interpreter at work somewhere in the
chain. Is that, in effect, what a wrapper does, interpret before
passing calls along to the library?

It looks like this issue is fixed in gtk 3.24.4, at leased for me i read
on the DLang forums you weren't so lucky.

It looks like it works properly when i have a full msys2 install, but
not when using the installer from gtkd.org.

Re: Submenu Not Responding Until Second Click

On Thu, 7 Feb 2019 23:28:56 +0100, Mike Wey wrote:

It looks like it works properly when i have a full msys2 install, but
not when using the installer from gtkd.org.

I take it you're talking about the gtk runtime?

Any idea what the difference is?

I found this: https://blogs.gnome.org/nacho/2014/08/01/how-to-build-your-gtk-application-on-windows/
which looks more or less relevant. Perhaps I'll try scraping off the runtime and reinstalling.

This sounds like it could also be used for packaging and distributing GtkD applications. Have you tried it? If not this one, do you know of one?

Re: Submenu Not Responding Until Second Click

On 08-02-2019 11:50, Ron Tarrant wrote:

On Thu, 7 Feb 2019 23:28:56 +0100, Mike Wey wrote:

It looks like it works properly when i have a full msys2 install, but
not when using the installer from gtkd.org.

I take it you're talking about the gtk runtime?

Yes,

Any idea what the difference is?

I looks like missing locale / translation files.

I found this: https://blogs.gnome.org/nacho/2014/08/01/how-to-build-your-gtk-application-on-windows/
which looks more or less relevant. Perhaps I'll try scraping off the runtime and reinstalling.

That is relevant, in the past i would compile the gtk runtime and it's
dependencies from source, but currently the installer uses the binaries
from msys2.

This sounds like it could also be used for packaging and distributing GtkD applications. Have you tried it? If not this one, do you know of one?