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"

Widget Casting issue object inheritance.

Hi,

So I made a scroll box widget, that widget has a local variable of text. On "Event Construct" a for each loop runs through an array of the local text variable. Then a second widget is created (this widget is a button with text on) the text variable is set (to the array Item) and a child is added to the scroll box object. (This saves me adding and naming the buttons manually and allows me to increase the number of buttons much faster in the future)

This all works fine and displays as it is supposed to, the list box works, the buttons are clickable and they have the correct text on them determined by the items in the array.

This issue I have is I would like each button to do something different when it is pressed, so I can't make one on clicked event otherwise all the buttons would do the same thing. (as each child is made from the same button) So I am trying a solution where by when the button is pressed it casts to the scroll box (in order to access the local variable array), then as a loop goes through the array I can use the index number and a branch system to determine what should happen from that index number. ( If index 0 add health, if index 1 add mana, ETC)

The issue I have is that when I cast to the scroll box it has no object attached and no object I attach to it allows it to cast, I am told either that it doesn't inherit from this object and it is rejected or warned that my cast would always fail. I have looked at similar questions on here and tried things such as "get user widget object" "Get all pawns of class" and so on. None of the solutions on here work for my predicament.

So how do I cast to a blueprint widget, when inside another blue print widget? Or how can I set up each button in a list box to do something different.

Thanks

Product Version: UE 4.20
Tags:
more ▼

asked Sep 26 '18 at 04:13 PM in Blueprint Scripting

avatar image

MAIKERU Jackson
8 1 6

avatar image Nebula Games Inc Sep 26 '18 at 08:12 PM

screen shots?

avatar image MAIKERU Jackson Oct 01 '18 at 09:28 AM

Hey, there isn't much to screen shot there is a "On clicked" button event attached to a widget cast that wont work because there is no object I can attach to make it to work. All the straight forward ways of casting to the widget do not seem to work.Without the cast I can't get to the variables stored in the widget locally.

If there is an alternate way to casting to the widget in order to set a button up that is a child event then that would be useful to know as well/instead. I am only casting to the widget because I am at a loss for any other way to do the same thing without it.

Thanks

avatar image MAIKERU Jackson Oct 01 '18 at 09:53 AM

alt text

avatar image MAIKERU Jackson Oct 01 '18 at 09:57 AM

This is how the list box fills with buttons, I just need to know how to make each button do something different when pressed. I can't set them up because they are not created until the list box is, so I would need to give them an action after their creation.

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

I have now solved this issue in a different way. My solution was to create a variable within the Player Controller and then set that variable to the widget I was trying to cast to, I could then access that reference through the player controller and then access the variables within the widget as required.

Thanks

alt text

more ▼

answered Oct 01 '18 at 11:54 AM

avatar image

MAIKERU Jackson
8 1 6

(comments are locked)
10|2000 characters needed characters left
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