I think the code was ok. The problem was with your scene setup.
I’d really suggest for you to check some ‘How to build UI with control nodes’ tutorials as I have a feeling that you haven’t checked these properly. Sorry in advance if I’m wrong
For example, the reasons your code didn’t work was:
First you had some Node2D scenes which was probably messing up the mouse event order
You put your script on the node named Control, and the script works depending on the boundary of that node. Maybe the boundaries were ok, but we couldn’t see them from here.
Your buttons were initially set up as Mouse filter Stop. So the mouse events were not propogating up.
@wchc I didn’t mean to take over, sorry about that I was just very excited to help someone finally in this forum and I have been working with my game’s UI for the last 2 weeks. So my brain has very fresh Control node information.
Hm, if I do KeepSize it blows up to be a massive image. Guess I’ll have to figure out how I want to control that. My guess is to just use a separate node as the image, but we will see
@lastbender Don’t worry about it, I don’t mind. I’m happy that the initial issue was resolved and you did great with you setup. Mine was definitely more messy and trial-n-error-based.
I wrongly assumed your root control is already stretched to a Full Rect, but it wasn’t. In this case, the signal caught only just the border around your buttons and that’s where the signals got caught entering and then immediately exiting. If you just stretched the root node fully, I think it would work properly. Nonetheless, the solution from @lastbender is basically the same, just structured a bit different, so don’t worry about my attempt.
Check the anchors for the TextureRect, when it’s on your main (or one up) scene.
Also to keep in mind, it’s wise to use seperate CanvasLayer for each UI menu.
So for your case, I think your whole inventory menu should be under a seperate CanvasLayer.
And if you have other UI windows, they also should be under a seperate CanvasLayer. Some examples:
Main Menu where it shows Load, Save or Quit game - usually when you press escape during the game
Information Menu - can be for a building, for an item or for a character
I should probably look up CanvasLayers. I know basically nothing about them, and I do have a lot of different UI elements. So if its the better way to go, I should learn it.