Opened 5 years ago

Last modified 3 years ago

#5405 new defect

Engine.GetGUIObjectByName doesn't work with objects with name parameter defined with javascript.

Reported by: nani Owned by:
Priority: Should Have Milestone: Backlog
Component: Core engine Keywords:
Cc: Patch:

Description

If you want to name an unnamed object (eg a child object) with javascript

object.name = "newName"

the name is stored but not accessible from javascript as

Engine.GetGUIOjectByName("newName")
// returns undefined

Change History (2)

comment:1 by elexis, 5 years ago

I suppose Expected Behavior: The property should remain read-only and throw an error upon assignment instead of silently ignoring the statement.

Since it seems more straight forward if the reader can examine the XML file, then know which GUI objects exist, their names, and then see how the names are used by the code.

The name property is in JSInterface*GUI*cpp somewhere, should be possible to mark that as permanent.

However there's actually code in JSI_IGUIObject::setProperty, if (propName == "name") for that case. I guess the GUI Page that stores the GUI objects is not updated. IMO it's cleaner to keep the names const, as mentioned, (also it keeps the code complexity lower), unless someone can demonstrate a good reason to allow that. (If one can achieve the same use case with const names with the same JS code complexity, it's not so clear that it would be a good reason.)

comment:2 by Stan, 3 years ago

Milestone: Alpha 24Backlog
Note: See TracTickets for help on using tickets.