When attaching a method to a button on a form it would be nice to allow the execution of a method on another form without having to create a method on the currently displayed form that calls the method on the other form. This would keep the number of methods in the forms, or global methods, down to a minimum.
I would envision something akin to the Filemaker “External Script” function.
Perhaps there could be a combobox at the top of the “Property Editor” box that could be populated with a valuelist of the names of the forms that appear in in the “Choose Form” window. When a form is selected from the combobox the Property Editor would show the form methods associated with that form. A method from a different form that is attached to an onAction event could be displayed as:
You are right. My example was flawed. Nevertheless, I still think it would be of benefit for Servoy development- and another reason to attract converts from the FMPRO Camp!
I would envision something akin to the Filemaker “External Script” function.
This does’nt make sense
In Filemaker you have to make an internal script too, before you can use the External Script-step
I think the suggestion would go something like presenting a custom option when choosing from the list of method options. This custom option would be an edit field where you could enter the name of the method, such as forms.myform.myMethod()
Although, you can do this today to some degree. Create a single global method that will trigger any number of methods on other forms. Then use the application.getMethodTriggerElementName() function to determine which button called the global method. You can then use an if/else or switch to run whichever form method you want.
You can even qualify this further using the application.getMethodTriggerFormName() in conjuction with the other function if you wanted to use buttons with the same name on different forms. Heck, if you think about it, you could have one single global method for all your onAction() buttons!
The combobox could be used to select other forms in the solution, which when selected would populate the “form methods” section with the methods from that form.
In the properties grid the onAction box would show selectedMethodName[selectedForm] as a way to show that the method is called from another form. I think this approach would be safer than typing the form and method name directly into a custom setting.
Using the global method seems undesirable to me because you would have to look at the global method code to determine which method will be executed rather than just glancing at the properties box.
ALso, this could be applied to all of the on… events too!