If we need to notify events to the caller form we can try this pattern:
In the child form, make a method named updateCaller and invoke it when you want to notify the parent:
void updateCaller()
{
Common common;
Object dataSource;
Object caller;
;
//-----------------------------------
//We are notifying using the dataSource
common = element.args().record();
if (common
&& common.isFormDataSource()
&& formDataSourceHasMethod(common.dataSource(), identifierstr(SomethingWasHappend)))
{
dataSource = common.dataSource();
dataSource.SomethingWasHappend();
}
//-----------------------------------
//-----------------------------------
//We are notifying using the form
caller = element.args().caller();
if (caller
&& classidget(caller) == classnum(SysSetupFormRun)
&& formHasMethod(caller, identifierstr(SomethingWasHappend)))
{
caller.SomethingWasHappend();
}
//-----------------------------------
}
Implement the handling method in the parent form:
void SomethingWasHappend()
{
;
info("Something was happend (Form)");
}
Or if you prefer, in the DataSource:
void SomethingWasHappend()
{
;
info("Something was happend (DataSource)");
}
Invoking it from a simple button inside the child form:
void clicked()
{
super();
element.updateCaller();
}
See a pratical sample in the form MarkupTrans (DataSource -> method write).
