Gui pick_node trouble (SOLVED)

#1

My current project’s gui fails to pick nodes during on_input. (using action’s x and y) I have another project with a similar gui set up which works fine. So I’ve done something wrong. I tried a test suggested in another Question post. [get the node. Get its position. Test the position with gui.pick_node]

self.brushes["01_bigTree"] = gui.get_node("01_bigTree")
gPos = gui.get_position(self.brushes["01_bigTree"])
pprint(gui.get_position(self.brushes["01_bigTree"]))
print(gui.pick_node(self.brushes["01_bigTree"], gPos.x, gPos.y))

…but the test fails. I’m using default settings, plus Monarch. Could that cause this problem?
(see the print output outlined in red at the bottom of this image) There are no errors listed in the console output.

0 Likes

#2

Have you tried using action.screen_x / action.screen_y ?

1 Like

#3

Strange. Are you using the default render script? I noticed that you have DefOS as a dependency. Are you resizing the window?

Can you pick a box node added to the root of the node hierarchy and added to the lower left corner of the screen? Or in the middle?

1 Like

#4

Good morning! (my time zone)

I tried screen_ , but no change.

I’m using the default render script. Nor am I making any calls to DefOS (yet) .

However, I was able to get the test code to work on a text node at the root of the Node folder. So it sounds like the Tools box is messing with its subordinate boxes. Doesn’t pick_node handle all the hierarchical coordinate deltas?

0 Likes

#5

After investigating the differences between the non-working project and the working project, the only significant difference I can find is that the non-working project has its gui inside a game object inside a collection that is treated by Monarch as a screen. Could that be relevant?

0 Likes

#6

Hmm, no I don’t think so. Are you able to share (send to bjorn@defold.se) a minimal project with the problem?

1 Like

#7

pick_node example.zip (9.2 MB)

Thanks for asking, @britzl . Good luck.

0 Likes

#8

I started your project and moved the mouse on top of the tree image:

The log:

DEBUG:SCRIPT: vmath.vector3(-240, 480, 0)
DEBUG:SCRIPT: false
DEBUG:SCRIPT: test's up
DEBUG:SCRIPT: picked: 01_bigTree
ERROR:GAMEOBJECT: Instance '/scriptsObj' could not be found when dispatching message 'set_the_brush' sent from Worksheet:/works#piecesTools

It looks like I’m able to pick the item, at least based on the log output. But there is also an error about a missing game object instance.

2 Likes

#9

Thanks for running the example. I don’t get that error, but it did pick the right object. So the reduced version works. (I didn’t see it because gui.get_position returns the object’s relative position, and the highlight goes into negative land. (my bad) )

So I took the working, minimal example and re-implemented the removed functionality. It’s now working. What can you do but call code black magic sometimes?

EDIT: I figured out why you got the error. There was an obsolete script file that my copy found that’s not in yours. So the message couldn’t get passed. Whereas, on my system the message went to the wrong file. I wish I had gotten the error!

3 Likes