Object.Parent?

Why can't I get the parent of an object?

A very simple example:

1) Create a new object TestParent. Everything is default except widget (Test) and size (200x200).
2) Create a new object TestChild. Everything is default except widget (Test) and it is a child of TestParent.
3) Create a script for TestChild as follows:
Code: vbscript
  1. Sub Object_OnMouseEnter
  2. Msgbox "This object's parent is " & Object.Parent.Object.Name
  3. End Sub

4) Apply everything, move the mouse over the small object, and bam!

DXScript: Scripting Error
Object Required: 'Object.Parent'

What is going on? The syntax is directly from the DesktopX documentation at https://www.stardock.com/products/desktopx/documentation/scripting/object_namespace.asp

Edit: DX 3.2 purchased version (with Object Desktop)
3,614 views 3 replies
Reply #1 Top
Well, this works
Code: vbscript
  1. opn = Object.ParentName
  2. l = DesktopX.Object(opn).Left
  3. Msgbox "Parent Left: " & l


I am still curious about Object.Parent. Since this is in the docs and pop-up code completion, I would think it would work as advertised.
Reply #2 Top
It seems as if object.parent.object.name only works if the parent is a scriptobject. Why this is the case I cannot say.

It might explain the inclusion of the additional property object.parentname, which would otherwise be redundant.
Reply #3 Top
Very curious, I never tried either of those but, wondered if it was a boolean value or not. From the TestParent object this one works.

Code: vbscript
  1. Sub Object_OnMouseEnterEx(obj)
  2. Select Case obj.name
  3. Case "TestChild"
  4. Msgbox "This object's parent is " & DesktopX.Object("TestChild").Parent.Object.Name
  5. End Select
  6. End Sub