I’m trying to make a game that uses a desktop layout with apps and windows and such. When I press the button to open the notes app I want it to only open the notes window if it wasn’t already opened before. To do this I made a boolean that will become true if the notes window closes, so when I open the app it will detect to see if the value is true and then open. If the value returns false then it wont do anything. However my problem is that I can’t get the widget with the notes app to read the boolean from the widget with the notes window.
Here are images for reference:
This is in my “Widget Notes” widget (the one with the notes window). When the x is clicked it sets the IsNotesClosed bool to true and moves the widget out of view to “close” it
Here, I am in the second widget. I’m detecting the double click, going through some branches (not important in this situation) and trying to run a function inside the first widget, but it always comes out as the default value
This is inside the function I am running. All it is doing is just getting the value of IsNotesClosed
I’d imagine it probably has to do with my method of getting the first widget into the second widget, and I couldn’t find any good way to do this. I’ve been stumped on this for a bit, so some advice would be good
P.S. I haven’t done much of this yet, so I imagine a lot of my code isn’t that good practically
Rather than using bools, have an actual reference to each widget. Also, keep all these somewhere central. The player is a good place, or the game instance. Where are you creating the widget?, that’s also a good place to keep the references ( unless it’s the level BP ).
That way, you know if the widget is on the screen, because the reference is valid ( because when you remove the widget, you set the reference to null ).
If you do this, you have references to all your widgets handy, and can communicate between them.
Hey! I actually just scrapped the idea but I think what you are saying would have actually worked. I gave it a try and after it didn’t work I scrapped it, but I just realized what I did wrong and yeah, what you said definitely helped, so thanks
A noob - but, I have two possible answers - first one, is create variable/reference to each of the widget classes inside each other (if there is only one of each, then this is easier). This is the simplest (completely BAD coding way of doing it… especially if you use a “all actors of class” X approach.
The better (?) alternative would be to create an interface (especially if it’s one way traffic) where you send a message from one widget and it’s ‘heard’ by the other widget. The thing I’m not entirely comfortable with is that to send messages you either need to specify the actor you’re sending it to (in which case why not just reference it directly) - or you grab all actors that use that specific interface (which might just be one). I’m sure others will provide better answers (I AM a NOOB after all).