x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How would one make a context menu in UMG c++ or Slate in game

As the question asks, I would like to know what is the approach (or best approach) to creating a context menu (right mouse click on other UMG/slate widgets) in game in UMG preferably but Slate with UMG interaction is fine too, c++ or blueprint. I've been trying a few things with more or less success so far, some solutions better than others, but still lacking in functionality.

So the first thing i tried was a completely blueprint solution, detect right mouse down, spawn a UserWidget blueprint widget on the viewport at the mouse location. The problem with this is a can't detect click outside the widget in order to close it. Tried a few things like having a transparent fullscreen overlay behind it, detect click on it, destroy the widget and overlay. A problem with this approach, somehow mouse focus is lost to game viewport, and the widgets behind the overlay are no longer responding to mouse events (ex roll over buttons) even if the mouse events callback return unhandled replies, and use onpreviewmousebuttondown. I also tried registering to FSlateApplication.PopupSupport.OnMouseclickoutside. It never triggered...

A second thing i tried to use UAnchorMenu widget object, to create it dynamically and place it at cursor location, set the content and call setisopen on it. Problems with it it is not closing automatically on click outside. When the anchormenu object is placed inside the current widget, the popup appears also inside, and gets hidden by other widgets. Didn't try putting it directly in the viewport instead, since it wasn't closing automatically, although i saw in the smenuanchor implementation it is binding to on mouseclickoutside event.

I also tried FSlateApplication.PushMenu - i had the most success with this one, the popup closes automatically when clicking outside, widgets behind this new window (PushMenu creates a new SWindow, is this ok for use inside a game, in SWindow i saw reference to native window...) keep responding to mouse events. All good... Except, my widget pushed seems to be losing its transparency, and instead the background is opaque black. I Looked through PushMenu implementation and saw that the new SWindow object has useTransparency only if animations are turned on and slate application not throttling, however the window is animating, sliding in from a right offset at the position it supposed to be, still the background is black.

I think i tried a few other things, each with problems of their own, however these are the most important i guess.

I am currently on 4.5 preview, moved from 4.4 where even to detect right mouse button down in UMG i had to go through hoops.

Any pointers, suggestions regarding this? Thanks in advance

Product Version: Not Selected
Tags:
more ▼

asked Oct 07 '14 at 01:01 PM in C++ Programming

avatar image

pinosh
16 2 3 6

avatar image Katianie Nov 14 '15 at 04:06 AM

I'm wondering the same thing.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Here's our answer: https://forums.unrealengine.com/showthread.php?25030-Slate-UI-Dynamic-Menu

UMG probably isn't going to have the support for one for a good while, so I am working on making a UI library using C++ and Slate where you can easily make drag and drop-able windows, context menu, message boxes, etc. The link above is what I used to get started with a context menu, Hope it helps.

more ▼

answered Jan 27 '16 at 11:28 PM

avatar image

Katianie
151 27 21 30

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question