Hi Mike,
Drag&Drop is a very powerful technique to create copies of classes, derive classes, derive variants of classes and create instances of classes. All with a single Drag&Drop operation. The default result of the operation depends primarily on the target where you drop something. Concrete:
- If you drop a class within a unit, a copy of the class is created.
- If you drop the class within another class (e.g. GUI component) an instance of the class is created. This is because, classes can't exist within another class.
This default behavior can additionally be controlled by pressing the keys CTRL, SHIFT and/or ALT before the Drag&Drop operation begins. If you holds the keys CTRL+SHIFT pressed, a new sub class is derived. If you press the keys CTRL+ALT, a new instance of the class is created. The actual effect of the operation is additionally visualized in the mouse pointer. For more details please see the section Drag & Drop members.
In your concrete case, as far as I understood, you wanted to create an autoobject within a unit, right? In such case you Drag&Drop the class Core::Time by pressing the keys CTRL+ALT. See also Create new autoobject. The workaround to add the object to a GUI component and then to copy/paste it is not necessary.
I need access to Time.CurrentTime in the entire application.
Is this the reason for the usage of the autoobject? In other words, you plan to access CurrentTime via this global autoobject only? If yes, all the steps described above to create class variant are superfluous. In such case:
Step 1. Delete the class variant again.
Step 2: Instead, derive a new class from the Core::Time class. Name it, for example, Application::RTCTime.
Step 3: Within your new RTCTime class override the method getCurrentTime and adapt it accordingly.
Step 4: Create a new autoobject of the new RTCTime class.
Now the autoobject is an instance of the RTCTime class and as such it uses the modified getCurrentTime method.
Is this what you are trying to achieve?
Best regards
Paul Banach