Thread overview
Submenu Not Responding Until Second Click
Feb 04, 2019
Ron Tarrant
Feb 05, 2019
WebFreak001
Feb 05, 2019
Ron Tarrant
Feb 05, 2019
Antonio Corbi
Feb 05, 2019
Ron Tarrant
Feb 05, 2019
Antonio Corbi
Feb 06, 2019
Ron Tarrant
Feb 07, 2019
Antonio Corbi
Feb 08, 2019
Ron Tarrant
Feb 08, 2019
Antonio Corbi
February 04, 2019
I posted about this over on the GtkD site, but I suspect no one's home until later in the day.

I've been writing up examples for menus and found some odd behaviour. Now I'm wondering if I've missed something.

The code compiles without error and runs.

But after the window opens, first click on the menu results in a blue line appearing under the menu title. Second click and the menu finally drops.

This is the code boiled down to the bare minimum. It a single menu with a single item which is a submenu and it, in turn, has a single item.

The original was more elaborate with multiple menus and multiple items, only one of which was a submenu. I've tried a number of variations, but it seems that submenus always cause this behaviour.

I've also tried various OOP versions of this code. Same result.

Any ideas about why this is happening? Bug? Bad code? Programmer not holding mouth in correct position?



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()



And it still does the same thing. First click, blue line. Second click, menu drops.
February 05, 2019
On Monday, 4 February 2019 at 18:34:55 UTC, Ron Tarrant wrote:
> I posted about this over on the GtkD site, but I suspect no one's home until later in the day.
>
> [...]

works fine here, can't reproduce with your example code. Maybe some GTK configuration of your system?
February 05, 2019
On Monday, 4 February 2019 at 18:34:55 UTC, Ron Tarrant wrote:
> I posted about this over on the GtkD site, but I suspect no one's home until later in the day.
>
> [...]


> And it still does the same thing. First click, blue line. Second click, menu drops.

Hi Ron:

It's working OK for me (gtkd 3.8.5).
Have you tweaked your gtk theme? If so, could you try with the default (Adwaita) gtk theme?

Antonio
February 05, 2019
On Tuesday, 5 February 2019 at 08:43:21 UTC, WebFreak001 wrote:

> works fine here, can't reproduce with your example code. Maybe some GTK configuration of your system?

From the questions you guys asked, I just realized I should have said I'm running on Windows 10.

February 05, 2019
On Tuesday, 5 February 2019 at 08:51:49 UTC, Antonio Corbi wrote:

> Have you tweaked your gtk theme? If so, could you try with the default (Adwaita) gtk theme?

This is a Linux/Gnome thing, I'm assuming? Still, I'll look into other configuration stuff and see where it leads. Thanks, Antonio.


February 05, 2019
On Tuesday, 5 February 2019 at 09:31:01 UTC, Ron Tarrant wrote:
> On Tuesday, 5 February 2019 at 08:51:49 UTC, Antonio Corbi wrote:
>
>> Have you tweaked your gtk theme? If so, could you try with the default (Adwaita) gtk theme?
>
> This is a Linux/Gnome thing, I'm assuming? Still, I'll look into other configuration stuff and see where it leads. Thanks, Antonio.

It could be so, I'm not using gnome so I can't say.
By the way, I'm using gtk3 3.24.5.

Antonio
February 06, 2019
On Tuesday, 5 February 2019 at 09:41:06 UTC, Antonio Corbi wrote:

> It could be so, I'm not using gnome so I can't say.
> By the way, I'm using gtk3 3.24.5.

Yeah, I updated from 3.22 to 3.24, but it made no difference on Windows 10. Still that delay with submenus.

I'd rather be running FreeBSD, but ATM I'm using an MSI laptop with two external monitors and I'm still working on getting Xorg configured to recognize even one of those external monitors. So, until then, I guess I'm stuck with this behaviour.


February 07, 2019
On Wednesday, 6 February 2019 at 13:13:44 UTC, Ron Tarrant wrote:
> On Tuesday, 5 February 2019 at 09:41:06 UTC, Antonio Corbi wrote:
>
>> It could be so, I'm not using gnome so I can't say.
>> By the way, I'm using gtk3 3.24.5.
>
> Yeah, I updated from 3.22 to 3.24, but it made no difference on Windows 10. Still that delay with submenus.
>
> I'd rather be running FreeBSD, but ATM I'm using an MSI laptop with two external monitors and I'm still working on getting Xorg configured to recognize even one of those external monitors. So, until then, I guess I'm stuck with this behaviour.

Hi Ron,

xrandr (and gui interfaces for it like arandr) are your friends here.

xrandr -q -> shows your card outputs and then you can use xrandr + options to configure monitors.

Or you can use arandr that will do that for you and will allow you to visually spatially-arrange your monitors.

Antonio
February 08, 2019
On Thursday, 7 February 2019 at 08:41:29 UTC, Antonio Corbi wrote:

> Hi Ron,
>
> xrandr (and gui interfaces for it like arandr) are your friends here.
>
> xrandr -q -> shows your card outputs and then you can use xrandr + options to configure monitors.
>
> Or you can use arandr that will do that for you and will allow you to visually spatially-arrange your monitors.
>
> Antonio

Thanks for the tip, Antonio. I'd never heard of xrandr or arandr. Must be new since I stopped paying attention a few years ago.
February 08, 2019
On Friday, 8 February 2019 at 10:03:03 UTC, Ron Tarrant wrote:
> On Thursday, 7 February 2019 at 08:41:29 UTC, Antonio Corbi wrote:
>
>> Hi Ron,
>>
>> xrandr (and gui interfaces for it like arandr) are your friends here.
>>
>> xrandr -q -> shows your card outputs and then you can use xrandr + options to configure monitors.
>>
>> Or you can use arandr that will do that for you and will allow you to visually spatially-arrange your monitors.
>>
>> Antonio
>
> Thanks for the tip, Antonio. I'd never heard of xrandr or arandr. Must be new since I stopped paying attention a few years ago.

No, xrandr has been around for a long time: https://www.x.org/wiki/Projects/XRandR/

It makes easier than xinerama to configure several monitors. For example when I start my xsession with an external monitor attached to the HDMI port, I switch-off the internal laptop panel and use only the external one, a small script like this does the trick:

xrandr | grep "HDMI-1 conn" >/dev/null
if [ $? = 0 ]
then
  xrandr --output HDMI-1 --auto --primary --output LVDS-1 --off
fi

Those names like HDMI-1 or LVDS-1 are the ones that 'xrandr' or 'xrandr -q' show you. Depending on the driver/card combination they may change.

Xrandr requires that your card driver supports it, nowadays it is the usual thing, but you'll have to check that.

Arandr (there are others) simplify the configure task due to their GUI based interface, though I prefer the text based interface that xrandr offers.

Antonio.