Giter Club home page Giter Club logo

simplemenubarbuilder's Introduction

SimpleMenuBarBuilder

Unreal Engine 4.26, Windows 10, Visual Studio 2019

I would like to use FMenuBarBuilder inside my application, and tried using UNativeWidgetHost to use the menu as a component of UMG. It was not so difficult to use FMenuBarBuilder through UNativeWidgetHost. The problem is that the menu is not rendered correctly.

Desktop 2022-01-14 - 09-58-04-06_1

Whenever the mouse cursor is moved to submenu, the owner’s hovered status seems to be removed. For example, when the mouse cursor is on “MenuB_1”, the background of “MenuB” should be kept orange, and the font color of “TestMenu” should be white. Both should be kept as the hovered status.

And when I click “MenuB”, the submenu disappears and appears, while it should not be disappeared.

The editor’s menu is of course rendered correctly, so it might not be a bug, but the side effect of using UNativeWidgetHost.

I found that the status of the owner of the submenu is decided by SMenuEntryBlock::ShouldSubMenuAppearHovered of SMenuEntryBlock.cpp and the status of

!OwnerMultiBoxWidget.Pin()->IsHovered()

is inversed whenever using FMenuBarBuilder through UNativeWidgetHost. So maybe OwnerMultiBoxWidget is not set correctly when using FMenuBarBuilder inside UNativeWidgetHost. If I remove "!" and modified the function to

bool SMenuEntryBlock::ShouldSubMenuAppearHovered() const
{
	// The sub-menu entry should appear hovered if the sub-menu is open.  Except in the case that the user is actually interacting with this menu.  
	// In that case we need to show what the user is selecting
	return MenuAnchor.IsValid() && MenuAnchor.Pin()->IsOpen() && OwnerMultiBoxWidget.Pin()->IsHovered();
}

Then the menu is rendered correctly. (The problem of disappearance of the submenu by clicking the owner still remains.)

I've upload whole the project code to GitHub. https://github.com/HSeo/SimpleMenuBarBuilder

Any comment would be very welcome. Thank you.

FMenuBarBuilderUMGTest

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.