question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enable using MenuBar as an alternative for ComboBox

See original GitHub issue

Is your feature request related to a problem? Please describe.

I have been exploring using a MenuBar as a dropdown menu. It works like a dropdown style combo box and looks better and gives clearer indication of what the active/new selections will be.

But there is a problem in that the user cannot Tab to the view. I have tried setting the following but it does not work.

CanFocus = true,
TabStop = true

menu-as-combo

Describe the solution you’d like Tab to work for MenuBar when TabStop is set.

Describe alternatives you’ve considered I can probably still do a workaround by intercepting Tab on the View before it and adding a callback to manually popping the menu open.

I will probably have to do this anyway so that the user can Tab out of the menu and back to other views.

Issue Analytics

  • State:open
  • Created 6 months ago
  • Comments:14

github_iconTop GitHub Comments

3reactions
tigcommented, Apr 23, 2023

Here’s a tweaked scenario. I realy love this!

		public override void Setup ()
		{
			var tf = new TextField () { Width = 10 };
			Application.Top.Add (tf);

			MenuBarItem menu = null;

			MenuItem CreateMenuItem (int i)
			{
				return new MenuItem ($"Item {i}", null, () => {
					tf.Text = menu.Children [i - 1].Title;
				});
			}

			menu = new MenuBarItem ($"{Application.Driver.DownArrow}",
				Enumerable.Range (1, 5).Select (
						(a) => CreateMenuItem (a))
					.ToArray ());

			var mb = new MenuBar (new [] { menu }) {
				CanFocus = true,
				Width = 1,
				Y = Pos.Top (tf),
				X = Pos.Right (tf)
			};

			// HACKS required to make this work:
			mb.Enter += (s, e) => {
				// BUG: This does not select menu item 0
				// Instead what happens is the first keystroke the user presses
				// gets swallowed and focus is moved to 0.  Result is that you have
				// to press down arrow twice to select first menu item and/or have to
				// press Tab twice to move focus back to TextField
				mb.OpenMenu ();
			};

			Application.Top.Add (mb);

This mostly works today as @tznind notes.

4Sl96Je 1

What needs to be fixed to make this really be done:

  • The menu should pop down aligned to the left of the textField.
  • MenuBorderStyle = LineStyle.None might look better
2reactions
tigcommented, Apr 19, 2023

Why isn’t Onfocus true by default?

Yesterday I was goofing with Focus stuff and realized it might make sense for Menubar to participate in tabstops along with the other subviews of a view.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I include a DropDownList in a menu bar using the ...
My suggestion is to use either a toolbar or a rebar control that simulates a menu bar, rather than the standard menu bar....
Read more >
CMFCMenuBar Class
CMFCMenuBar ::EnableHelpCombobox. Enables a Help combo box that is located on the right side of the menu bar. C++
Read more >
Binding Dropdown Menus and Combo Boxes - Python Tkinter ...
In this video I'll show you how to bind drop down menus (OptionMenus) and Combo Boxes with tKinter and Python so that you...
Read more >
How to Use Menus (The Java™ Tutorials > Creating ...
A popup menu is a menu that is invisible until the user makes a platform-specific mouse action, such as pressing the right mouse...
Read more >
Appending New Dropdown Option on MenuBar? (Pycharm ...
I went through the hooks and the toolbar hook worked but it is not ... this code on pycharm append an extra dropdown...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found