After using OBJECT Get pointer(Object current)->:=New 
object("subformName";OBJECT Get name(Object current)), I got Form ={} or 
Form=null, depending on where the code was put (subform's form method or 
container's method).


If the subform container's code is:
-------
Case of 
        : (Form event=On Load)
                $name:=OBJECT Get name(Object current)
                EXECUTE METHOD IN SUBFORM($name;"setFormName";*;$name)
End case 
-------

and the setFormName method is:
-------
C_TEXT($1)
OB SET(Form;"subformName";$1)
-------

Objects in the widget can see the Parent form's name for their container in 
Form.subformName.
But it only works if the container's Variable Type is set to "None", and fails 
(Form=null) when the Type is set to "Object".

1) I was not expecting only "None" to work.
2) Is there a way for a widget's objects to know the container's name without 
help from the Host?  (Anything available from the inside?)

Thanks,
Keith - CDI

> On Jul 8, 2019, at 1:29 PM, Add Komoncharoensiri via 4D_Tech 
> <[email protected]> wrote:
> 
> Hi Chris,
> 
> Since your Subform Widget will be set to Object type, you can try this 
> approach.
> 
> Create the object method for you subform widget with the following code:
> 
> If (Form event=On Load)
>    OBJECT Get pointer(Object current)->:=New object("subformName";OBJECT Get 
> name(Object current))
> End if
> 
> Basically you are create a new property to your Form-data of the Subform 
> Widget named "subformName". Once the form is loaded, you can find out the 
> name of your subform container from the context of your subform execution 
> simply by calling:
> 
>    Form.subformName
> 
> HTH,
> Add
> 
> 
> 
> 
> On 7/8/19, 10:46 AM, "4D_Tech on behalf of Chris Belanger via 4D_Tech" 
> <[email protected] on behalf of [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]
>    **********************************************************************
> 
> **********************************************************************
> 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]
> **********************************************************************

**********************************************************************
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]
**********************************************************************

Reply via email to