Page 1 of 1

Accessing a loaded form's method by a different active form

Posted: Wed Oct 14, 2015 9:07 am
by Marked
Hey guys

I'm trying to figure out how to run another form's method from another, active form. Both forms are open. There is a main form and then a pop-up form. From the pop-up form, I want to run a method of the main (basically to refresh something). I want to run the method when a button on the pop-up form is loaded.

For some reason, I just can't get the instance to access the main forum, even though it is open and running. It's just not the active form.

I have looked at this topic
https://forums.jadeworld.com/viewtopic.php?t=1546

But by doing this;

Code: Select all

frm := app.getForm("mainMenu").Form;
I am able to set the forms properties, but not run its methods.

Any help is appreciated

Thanks in advance
Mark

Re: Accessing a loaded form's method by a different active form

Posted: Wed Oct 14, 2015 10:59 am
by allistar
If a popup or modal form is being shown from a main parent form I would give both forms a reference to the each other. Then getting the form would be a case of using the "myParentForm" or "myPopupForm" reference.

It's good practice to not set properties on another object directly. A more encapsulated was is to have a setter method that does it for you. By default I make all properties "protected". Unfortunately JADE sets the access mode on control properties to be "public" which I think is a design mistake. They should be protected or at the very least read-only.

Re: Accessing a loaded form's method by a different active form

Posted: Wed Oct 14, 2015 7:13 pm
by Marked
Perfect :) Works like a charm. I never thought about whether or not forms have references like objects.

Re: Accessing a loaded form's method by a different active form

Posted: Thu Oct 15, 2015 9:13 am
by allistar
A form *is* an object :-)