WPF Why can I not see submenu during design and which is only partially viewed during runtime? - menu

here is my XAML code, It is very simple just for example. I am trying to build this example in VS-2022 and simply trying to understand why the results are counterintuitive. Obviously I am very new to WPF programming.
[ Xaml code]
1
As can be seen I am simply adding a menu bar that has one item Header="File" within that MenuItem I add a submenu Header="New". What I expect to see in the XAML designer window is something like this
expected XAML Designer window
What I see is nothing but the "File" header.
Can anyone explain why I do not see the Header="New" in the designer Window?
I ran the application and the "New" item appears as shown here:
I run the app and see this
I would have expected that at least the submenu would have shown inside the application window. I have run into this anomaly on several projects and cannot seem to get a straightforward simple answer to my questions which are two?
Why can I not see the submenu in the designer window during design?
Why does the submenu appear partially outside of the main app window during runtime?

Related

How to display overflow menu for ToolItems in a GTK Toolbar

A GTK Toolbar can display an overflow menu when the toolbar is not wide enough to show its contents.
It seems that this feature doesn't work if the toolbar contains ComboBoxes wrapped by ToolItems.
Here is an example code that demonstrates the issue. It's written in Haskell but I guess it shouldn't be too difficult to translate it into other languages.
The instructions to build the repo is written in the README.md.
The last command opens a small GTK window. If you make it bigger you'll see two ComboBoxes in the window. The problem is that if you make the window narrower a bit, the right ComboBox disappears and no overflow menu appears even though toolbarShowArrow is enabled.
(Unfortunately I don't have enough reputation on SO to post two screenshots here so I uploaded them on the repo.)
Interestingly if I change the contents of the Toolbar from ToolItems to ToolButtons for example, I get the overflow menu.
Also I tested this with 3 packages: gtk for GTK2, gtk3 for GTK3, and gi-gtk for GTK3 with gobject introspection. All of them have the same issue.
So the question is: is there any workaround for this issue?
The documentation states this about gtk_toolbar_set_show_arrow():
Sets whether to show an overflow menu when toolbar doesn’t have room for all items on it. If TRUE, items that there are not room are available through an overflow menu.
So, it's an "overflow menu". I won't bore you with a detour into the GTK+ source, but suffice it to say: the items you add to the Toolbar need to provide menu items to appear in its overflow menu. Sounds logical now, right? :D
ToolButtons work because they call set_proxy_menu_item() with a MenuItem they create specifically for this purpose.
And that's what Toolbar looks for when deciding whether items can overflow: proxy MenuItems, which it can put into the overflow menu - and only if it finds at least one is there any point in giving the arrow to open that menu.
So, if you have other widgets, you can to get them into the overflow menu by setting a proxy menu item on your ToolItem, by either of:
simply calling gtk_tool_item_set_proxy_menu_item() to set a specific item
connecting to the ::create-menu-proxy signal on your ToolItem, and deciding during each emission whether or not to set (or clear) the proxy item
You'd also, of course, connect ::activate on that MenuItem to do something appropriate relating to the original ToolItem.
...though whether you can do anything useful from a MenuItem if the ultimate ToolItem child is a ComboBox is a different question. It doesn't expose its popup menu as something you can use. I guess you could just add a duplicate of the ComboBox to a MenuItem and use that as your proxy... But in that case, likely you're outwith the scope of what the overflow menu is meant for, and should instead just ensure your Toolbar doesn't get small enough to lose such controls.
Or maybe not! Try it and see how it goes.

Dojo context menu - set menu item status dynamically

I am trying to implement a context menu on a dijit tree, and the context menu should display different contents and enable/disable the menu items based on which tree node I right-clicked on. Basically what I need is a pre-processing function that gets called before the context menu is displayed where I can run some logic to determine which menu items to show/hide, enable/disable, etc. I feel like this is a very basic functionality for context menus but wasn't able to find the solution, so I'm asking people for help.
Any help would be appreciated. Thanks!
Dijit Tree has no built-in support for context menus, but you can use the Menu widget in conjunction with the Tree. The Menu widget is used for context menus, with right-click which can really suite your use-case.
Documentation and examples here:
https://dojotoolkit.org/reference-guide/1.10/dijit/Tree.html#context-menu
https://dojotoolkit.org/reference-guide/1.10/dijit/Menu.html

Visual Studio 2015 Layout: Error List and Output

Problem: Having read this article, the initial intention was to dock the tabbed Error List and Output Windows to the IDE status bar, but won't accommodate as it seems this method is not implemented in the IDE interface.
Alternatively try raising the bottom edge of the IDE and move the Error List and Output below the IDE Window. Almost perfect except it squinches the right-docked Solution and Property Windows a little.
Now tabbed and grouped documents can be resized if they aren't docked to the top frame, but then the group becomes another Window outside the IDE (Win 8.11).
Questions: Is there a way to raise the bottom borders of the IDE docked document group to fit the Error List and Output?
That way it's not necessary to keep switching Window configs or hiding Error List & Output as we wish for a clear view of all content in a web page or document.
Or, as there's idle real estate either to the right of the IDE menu items or adjacent to the Notifications/Feedback/Quick Launch/ area is it possible to place buttons binding Window layouts to Ctrl+Alt+{num}?
Also reviving a question for previous VS version as a corollary, is there some way to bring back the old SDI feel of VB where the white space in the IDE is replaced by the desktop or another underlying window?
Helpful answers appreciated as always.

Menu Button that does not dismiss options onclick in JavaFX 2

I am quite new in JavaFX and I have a question about the design. I am creating my main menu in FXML using Scene Builder. I have various menu buttons and each of these have a sub-menu. These sub-menu options will open new windows. Is it possible to declare these submenu choices so they do not dissapear after I click on them? If so, can I declare it in my fxml or I have to do it programatically?
Also, is it possible to detach it from the menu button? I would like to have my menu choices around 1 cm away from the menu button itself.
Thank you
Suggested Alternate Solution
If you want more flexibility in positioning a popup menu after a button click as well as fine control over when the menu shows and hides, try using a Button + a ContextMenu rather than a MenuButton.
The relevant methods are:
contextMenu.show(anchorNode, side, dx, dy)
contextMenu.hide()
There is sample code for triggering a context menu on a button press button in the ContextMenu javadoc.
You might also need to monitor the context menu's showingProperty and in a listener show the menu again if the JavaFX system has decided to try and hide it after some user action and you still want the menu visible.
Answers to additional unrelated comments
OK It sounds logical, yet since Im not really good in JavaFX yet, your Idea is quite challenging.
It's not that hard to implement, but from your subsequent comments it sounds like it's probably not the user interface you want for your users anyway (which makes sense to me because the interface you describe in your question seems a little strange).
I thought If it would be easier to have a static xml that have various menu choices, lets say aligned to the right and then whenever I click one of the choices, a new FXML would be loaded in the middle of the screen holding buttons for a submenu?
That seems logical. Sounds like a JavaFX version of a traditional web page layout with a navigation menu on the side controlling a content pane in the center.
A Java only version of that is: How to have menus in java desktop application. You could adapt that to a FXML based version without too much difficulty.
You might also be interested in Managing Multiple Screens in JavaFX.
Also, any tutorial for beginners would be greatly appreciated. These Oracle ones dont make too much sense for me
If you are beginning JavaFX, I recommend using just the Java API portions of JavaFX until you become familiar with them, and then use FXML only after you are comfortable with the Java API.
Personally, I think the Oracle JavaFX Tutorials are excellent. The difficulty for beginners is that the tutorials are also part reference material, which complicates portions of them (especially the deployment related pieces).
If you prefer a different tutorial style see:
Makery JavaFX tutorial (good for beginners)
zenjava tutorials (more advanced)

How to skin MFC main menu

I got a menu in an existing MFC application that has a standard MFC main menu.
But I would like to change its background colour so that it appears to more seamlessly belong to the rest of the application.
First picture: An MFC main menu. The application is skinned blue, as seen in the toolbar, but the menu is still standard grey background colour.
Second Picture: Spotify's menu, skinned to fit into the rest of the
colors.
I have not found any examples on anything similar. Could you please point me towards how to achieve this?
Approaches I thought of:
Subclassing CMenu to my own SkinnedMenu, but it is not created by our code but by a GetMenu() call in a mainframe class deriving from CFrameWnd. The only thing I can find here is its method signature, defined in afxwin.h so then how could I make use my own subclassed menu?
Removing the entire menu and add my own custom menu buttons, in a row, making it look like a menu. Maybe this is what spotify have done, as they have also removed the Windows window frame.
Editing the existing CMenu in some way, but the only customization I am able to find right now is modifying its MENUINFO. For example if I set info.hbrBack = skin.GetSysColorBrush(COLOR_MENU) the only colour that changes is the background of the dropdown, not the main menu itself.
Other :)

Resources