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"

4.5 UMG - how to get OnMouseButton events?

I wan't to have global OnMouseButton Up/Down events in my widget. I've created new widget, implemented this event but it isn't fired up.

Anyone know how to enable this input in widget? Maybe I misunderstand those global events in widgets.

Product Version: Not Selected
more ▼

asked Oct 24 '14 at 11:02 AM in Using UE4

avatar image

677 71 92 148

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

3 answers: sort voted first

Hello intoxicat3,

First off I apologize for the misleading information I gave you the first time. I misunderstood your original post. I thought you wanted the Pressed and Release events specifically. However, I may be able to assist you with a workaround for your issue. This will allow you to click "off" of a widget and close it without using the player controller. You will see why I used quotes when you read through the example.

This will require:

  1. Widget blueprint

  2. Image widget the size of the designer window (alpha set to zero)

  3. A widget you would like to close (in the example it's a button)

You will need to drag an image widget into your designer tab and scale up so that it takes up the entire work space. You will then want to set it's alpha to 0.0 (effectively rendering it invisible). You may also want to set it's Zorder to 0 and the rest of the widgets to 1 or more (in this case it's my button that's set to 1). alt text

You will then want to scroll to the bottom of the detail panel and change the event to an on mouse down event. You will then bind this event. alt text

For the final step you simply have this function remove the widget from viewport. alt text

I hope this helps.

Make it a great day

clickoff1.png (48.9 kB)
clickoff2.png (48.0 kB)
clickoff3.png (39.2 kB)
more ▼

answered Nov 03 '14 at 03:44 PM

avatar image

Rudy Q ♦♦ STAFF
47.3k 545 132 525

avatar image intoxicat3 Nov 03 '14 at 04:50 PM

Thanks for this!

One question thou - alpha 0 means transparency on full resolution? On mobile this will slow performance a lot.

avatar image Nick Darnell ♦♦ STAFF Nov 03 '14 at 05:18 PM

Yes it will, instead just change the Draw As to None/No Draw Type. That will actually prevent slate from generating triangles for that quad. Also, you should return Handled from that function if you're handing the event, otherwise it will continue to bubble up through the hierarchy.

Also for your use-case, we've got a Menu Anchor widget coming in 4.6. More or less takes care of several of those aspects; like it spawns the popup, and dismisses it if it loses focus.

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

Mouse input definitely is supported - needs more documentation though! :D

By default, a user widget does not handle mouse input, since normally you want things to fall through and not do extra work. The Visibility property of a user widget controls more than hidden or visible, it also controls Hit Testing. If a widget is not hit testable it will not respond to the mouse.

UserWidgets default to SelfHitTestInvisible. So the widget is not hit testable, but all children are.

In widget blueprint editor, click on [Root] in the hierarchy. There you can configure the default visibility of your user widget. If you change it to Visible, it will become hit testable and its mouse events will be called :)

Not sure I understand what you mean by "Global", there's no such thing as a global handler in Slate/UMG for receiving any and all mouse events or otherwise. You only get events that your widget is privy to, based on what the user clicks on, hovers...etc, focuses...etc.

Cheers, Nick

more ▼

answered Oct 30 '14 at 01:06 AM

avatar image

Nick Darnell ♦♦ STAFF
6k 77 37 151

avatar image intoxicat3 Oct 31 '14 at 07:52 PM

Thanks Nick for answer! I'm talking about those events which we can implement - those aren't working event with Visible root.alt text

asd.png (33.2 kB)
avatar image intoxicat3 Oct 31 '14 at 07:54 PM

What I'm trying to do is to create small popups that can be closed when we click outside of them, like in many games. If there will be mouse events / touch events inside widgets I would be able to do that inside a widget without moving into input from player controller.

If there is known way to do something I would like to do please let me know :)

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

Hello intoxicat3,

The UMG system does not currently support mouse input. However, you could try casting from the your character blueprint to the widget. Here is an example:

alt text

alt text I hope this helps.


castinghelp2.png (24.1 kB)
castinghelp.png (51.0 kB)
more ▼

answered Oct 24 '14 at 04:13 PM

avatar image

Rudy Q ♦♦ STAFF
47.3k 545 132 525

(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