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"

Cannot cast On Button Click from Widget A to Custom Event/Function on Widget B

Hello there. :3

I have two widgets. Widget A contains just a button. Widget B contains a custom event that I want to fire each time the button on Widget A is pressed. Widget B also contains a test button to make sure the line of commands I want carried out are functional. When I press the test button in Widget B, it works exactly how I want it to. When I press the button in Widget A, nothing happens.

I've tried for several hours, looked at several tutorials, and for some reason I can't quite figure it out.

I've tried doing a "call" but I don't even get the option to "call" anything when I type it whilst blueprinting.

Also, when I try casting from Widget A to Widget B, it states "Widget A does not inherit from "Button" and it fails to cast.

Could someone show me the proper way to construct these widgets so that A can communicate with B?

Thank you.

Product Version: UE 4.22
Tags:
more ▼

asked Jun 18 '19 at 10:24 PM in Using UE4

avatar image

Xeromyr
3 1 1

avatar image Xeromyr Jun 19 '19 at 03:09 AM

Hey! Both of your answers were adequate solutions, thank you so much.

I do have to note however that I needed to uncheck "top Level Only" in order to get the first suggestion to work.

Once again, thanks a ton. I knew it would be something really simple in the end, haha.

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

3 answers: sort voted first

I was having the same problem calling functions between widgets and working with buttons. This youtube video from Nebula Games (thanks!) should help. But instead of using GetAllActorsOfClass, use GetAllWidgetsOfClass. This should do the trick: alt text The On_Clicked event is from WidgetA and when it is clicked, the DisplayMessage function I created in WidgetB prints a string message.

more ▼

answered Jun 19 '19 at 12:18 AM

avatar image

that_lightworker
51 1 3 3

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

Ok so I was able to reproduced this and get what you want - here's how I set it up..

Use the character or player controller as a third party communicator

Choose one - and inside create 2 "New Variables". The Variable types should be the widgets you created (See pic 1) {I used my character/ controller works too} alt text

Next - on event construct In both WidgetBP's , cast to character/controller (whichever you chose) and for each widget set "self" to the 3rd party BP's corresponding references (See Pics 2 & 3) alt text alt text

Now your 3rd party will have valid references to each widget, eliminating the need to cast to them (See Pics 4 & 5) alt text alt text

Best of Luck

screenshot-941.png (619.8 kB)
screenshot-942.png (484.6 kB)
screenshot-943.png (485.9 kB)
screenshot-944.png (485.3 kB)
screenshot-945.png (500.6 kB)
more ▼

answered Jun 19 '19 at 12:20 AM

avatar image

vicecore
58 4 6 11

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

Ok so I was able to reproduced this and get what you want - here's how I set it up..

Use the character or player controller as a third party communicator

Choose one - and inside create 2 "New Variables". The Variable types should be the widgets you created (See pic 1) {I used my character/ controller works too} alt text

Next - on event construct In both WidgetBP's , cast to character/controller (whichever you chose) and for each widget set "self" to the 3rd party BP's corresponding references (See Pics 2 & 3) alt text alt text

Now your 3rd party will have valid references to each widget, eliminating the need to cast to them (See Pics 4 & 5) alt text alt text

Best of Luck

screenshot-941.png (619.8 kB)
screenshot-942.png (484.6 kB)
screenshot-943.png (485.9 kB)
screenshot-944.png (485.3 kB)
screenshot-945.png (500.6 kB)
more ▼

answered Jun 19 '19 at 12:20 AM

avatar image

vicecore
58 4 6 11

(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