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

Forums for specific tips, techniques and example code
Marked
Posts: 2
Joined: Wed Oct 14, 2015 9:02 am

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

Postby Marked » Wed Oct 14, 2015 9:07 am

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

allistar
Posts: 156
Joined: Fri Aug 14, 2009 11:02 am
Location: Mount Maunganui, Tauranga

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

Postby allistar » Wed Oct 14, 2015 10:59 am

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.

Marked
Posts: 2
Joined: Wed Oct 14, 2015 9:02 am

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

Postby Marked » Wed Oct 14, 2015 7:13 pm

Perfect :) Works like a charm. I never thought about whether or not forms have references like objects.

allistar
Posts: 156
Joined: Fri Aug 14, 2009 11:02 am
Location: Mount Maunganui, Tauranga

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

Postby allistar » Thu Oct 15, 2015 9:13 am

A form *is* an object :-)


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 1 guest

cron