Log In    |    Knowledge Base    |    4D Home
Tech Tip: The Command "Last Object" under Windows
Published On: October 11, 2002

Compatibility: Version: 6.7.x and 6.8.x

The command "Last Object" returns a pointer to the last enterable object. This is quite useful if you want to implement a button which will populate the last enterable object the cursor was in with data when clicked. (field, variable, etc.)

You should be able to do this:

$ptr_LastObject:=Last Object
$ptr_LastObject->:=Current Date

The problem with this under Windows, is that Windows buttons by default are enterable objects; Hence, instead of returning the field or variable object, "Last Object" returns a pointer to the button.

A quick fix to this is simply to create the pointer yourself. In the object method for the field, create a pointer to the object:


In the object method for the button, use the pointer created:

Ptr_LastObject->:=Current Date

Note: make sure you enable the "on getting focus" event for the field object.