Is there a way to append a menu item to the popup menu that appears by default on right-clicking a GtkNotebook's tab (the one that contains the names of all the open tabs)?
As a somewhat gross hack, it might be possible to use gtk_notebook_get_menu_label() to get the GtkLabel in one of the tab's menu items on that menu, and then use parent-walking from there to find the menu.
Possibly this only works when the menu is being realized/shown, you could try adding event handlers on that label to detect that.
On the other hand, user4815162342's suggestion of re-implementing the menu is way easier.
Looking at the source code, it would appear that there is no way to append to the existing menu: the menu is kept in a private structure, and it is popped up directly on button-press event.
You can disable the default menu, connect to button-press event, and popup your own menu.
Related
My question might be simple but I couldn't find specific answer on web.
I have a winforms application with a grid inside, in which I have implemented a context menu to be shown on right click on cells. These cells include text elements that can be edited. When user clicks or double clicks on the cell, the text can be edited and that's what I want. The problem is when the text is in edit mode and user right clicks on it again, 2 context menus are shown on each other. One is my context menu and the other is windows right click on text including options like copy, paste etc.
I wonder if there is any event like "text being edited" or "windows default context menu opened" that can be used for such scenarios? Or what is the proper way of solving this problem, which I guess must be a common one.
In these cases I want to show only the windows right-click menu, not mine.
Perhaps you need the Control.GotFocus event: https://msdn.microsoft.com/en-us/library/system.windows.forms.control.gotfocus%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
You could look for focus, then prevent right clicks in the control until the control has lost focus (Control.LostFocus). If the control gets focus from a right click, then you could open your context menu (I think).
I am trying to have a small form in my menu item. I have split button that has one item. In that item I have form: datefield, textfield, button, etc...
The issue is connected with some keystrokes such as left arrow, right arrow. This key events are supposed to hide menu item by default. Now I need to disable them since every time an arrow button is used in my textfield, it hides the menu.
I am using beforehide event, but cannot find a way to achieve to my goal. I could not find any events similar to keydown to handle this case.
One more key backspace is also used for editing the textfield, but this one redirects the browser.
IN SHORT: I want to be able to freely use the keyboard in my menu item's textfield without hiding it. Is this possible?
Just use enableKeyNav: false in the menu configuration. From the doc:
enableKeyNav : Boolean
True to enable keyboard navigation for
controlling the menu. This option should generally be disabled when
form fields are being used inside the menu.
Defaults to: true
I need my menu (opened by a menubutton) to stay open after you select an item from the menu. So that you can select more then one items before it closes (by clicking outside of the list)
I couldn't find anything in the api, so i hope you guys know the trick
Another solution would be if you hover over the button, then the menu opens. When you leave the menu with your mouse, the menu would close.
Cross post from the mailing List:
http://qooxdoo.678.n2.nabble.com/Keeping-a-menu-open-after-selecting-an-option-td7580767.html;cid=1345706918184-716
Answer from the list:
In order to keep the menu open after clicks, you need to provide your
own implementation of menu.Button. You can subclass qx.ui.menu.Button,
and then need to overwrite the _onClick method so it doens't call
qx.ui.menu.Manager.hideAll (Have a look on qx.ui.menu.Button source code).
Then, onMouseout of the entire menu, call
qx.ui.menu.Manager.getInstance().hideAll().
In my WPF application I would like to get a dropdown menu under some other elements in the window. When menu is expanded it overlaps other controls. But I need these controls remain over the menu anytime.
I tried to play with ZIndex, but without any success.
Is it possible somehow to show dropdown menu under other controls?
Thanks for help!
You cannot achieve this with a drop-down menu, because by definition it is displayed on a separate window above the current window.
So if you want some control to appear under other controls, you have to use just normal controls like Grid, make them invisible at the beginning, and show as soon as you need the "dropdown" to appear (and of course hide afterwards).
I'm trying to show a context menu when I left-click a NotifyIcon. Just calling NotifyIcon.ContextMenuStrip.Show() doesn't work very well. A solution has been posted here before that calls a secret method using Reflection:
Dim mi As System.Reflection.MethodInfo = GetType(NotifyIcon).GetMethod("ShowContextMenu", Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic)
mi.Invoke(Icon, Nothing)
This works great, except that I also need to control where the menu is shown. I want to wait for the SystemInformation.DoubleClickTime to elapse between receiving the NotifyIcon.MouseUp event and displaying the menu, so that I can handle single-clicks and double-clicks separately. But invoking the ShowContextMenu method displays the menu at the current mouse position when ShowContextMenu is called, not when the icon was actually clicked. Which means that if the mouse moved during the DoubleClickTime, the menu will be displayed in a different part of the screen. So if I can control where the menu is shown, I can just save the mouse coordinates when I receive the MouseUp event, and then I can ensure that the menu is displayed near the icon. Is there a way to do this?
Thanks in advance.
Well, I just discovered that there are existing programs that exhibit this same behavior. I just went through all the icons in my system tray and about half of them do it. If you left-click the icon and then move the mouse during the delay before the menu appears, the menu will appear at the last mouse location, wherever that is on the screen. Snagit is one application that does this. Outlook is the only program in my tray that always shows the menu where I clicked the icon. But Snagit looks like it's using a .NET ContextMenuStrip, while Outlook is probably using a native menu.
So either this is standard behavior, or it's a problem that no one else has been able to solve either. And as a user, I've never noticed this behavior until yesterday when I was testing my own application. So I guess it's not that big of a deal and I won't worry about it.