SOLUTION:
On the parent form:
The CONTAINER’s bound variable is an OBJECT (in particular, the entity I am
editing).
The CONTAINER SCRIPT is:
// script of the included formDate CONTAINER
Case of
: (Form event=On Load)
EXECUTE METHOD IN SUBFORM(OBJECT Get
name;"SET_FORM_OBJ_ATTR";*;"formDate") // formDate is the attribute we want
handled by the widget
End case
“formDate” in this instance is the ATTRIBUTE we want the widget to operate on.
— THIS will be the entire configuration process for the widget! (as far as the
parent is concerned).
IN THE WIDGET COMPONENT:
// SET_FORM_OBJ_ATTR ( AttributeName ) -- this is the name of the ATTRIBUTE
we are GET / SETTING.
// for example, it may be "formDate" and it will be used as
“Form[Attribute]. to SET or GET the value from the CONTAINER's OBJECT
This value is stored in the widget’s special ‘ formData’ object as an attribute
named “sourceAttr"
C_TEXT($1) // the attribute name where the value is stored
$formObjPtr:=OBJECT Get pointer(Object named;"formData") // this is the object
on the form where we are storing the 'form data'
If ($formObjPtr->=Null) // no object? then we need to create it. This will
always be the case when this is called
$formObjPtr->:=New object
end if
$obj_FormData:=OBJECT Get pointer(Object named;"formData")-> // this is the
form data object
$obj_FormData.sourceAttr:=$1
IN THE WIDGET:
I created an OBJECT VARIABLE in the widget form. It’s object name is
“formData"
I use this OBJECT VARIABLE like I would have the Form. object. That way, the
attributes I set do not become part of the CONTAINER OBJECT.
• the GET / SET attribute name is .sourceAttr.
To manipulate this object:
$obj_FormData:=OBJECT Get pointer(Object named;"formData")-> // this is the
form data object
Then the attributes can be manipulated with $obj_FormData. attribute
So to get / set the SOURCE ATTRIBUTE that we are editing:
$obj_FormData.sourceAttr // this will be the DATE we are editing.
Any other data I need to store for this operation (such as
• .theDate — retrieved from the sourceAttr ($obj_FormData.sourceAttr)
• .theDay
• .theMonth
• .theYear
etc. all the data I need to store to handle the widget.
NOW:
• whenever the source object is changed (entity!) — the ‘On Bound Variable
Change’ is triggered in the Widget.
I can get the DATE I need to edit using the
.obj_FormData.sourceAttr method explained above. Then I can update the stuff I
need (.theDay, .theMonth, .theYear etc).
ON DEACTIVATE — I can update the CONTAINER’s date attribute as needed:
Form[$obj_FormData.sourceAttr]:=$obj_FormData.theDate // copy the result to
the bound Object's DATE Attribute we were editing
———
without doing too much more explaining, those are the things I discovered will
work.
In short:
I put an OBJECT VARIABLE onto the widget’s form.
I use this object variable to store the information I need to manage.
I tell the widget the name of the attribute that it is working on inside the
CONTAINER OBJECT. This is stored as an attribute in that special var
I can GET / SET the value in that attribute as per above (It is Form [ name
of attribute ] ) !
hope that helps.
I look forward to getting my widgets made and perhaps others may be interested
in using them.
I thank the developers that chimed in on this matter for me. I appreciate it.
— Chris
> On Jul 8, 2019, at 11:46 AM, Chris Belanger <[email protected]> wrote:
>
> I am trying to create my own widgets. Widgets are subforms.
>
> In the parent form, I want the INSTANCE bound variable to be an object.
> Inside the FORM METHOD of the widget (i.e. subform) I need to be able to find
> out the OBJECT NAME of the Parent INSTANCE of this widget.
> But I cannot find any command that will actually retrieve this information
> from within the widget’s form method when the INSTANCE is of type Object.
>
> In the subform’s method:
> OBJECT Get pointer(Object with focus) = nil
> OBJECT Get pointer(Object current) = nil
> OBJECT Get name(subform) = “”
> OBJECT Get pointer(Object subform container) = nil
>
> ————
>
> *** So how does the subform’s form method find out the name of its INSTANCE
> in the parent form? ***
>
> This is ridiculous if it cannot just because the bound variable is an object…
>
> Please, someone, put me out of my misery by sharing the secret. I cannot see
> why the widget’s method cannot find out ‘who it belongs to’.
>
> — Chris
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************