Bug #4907
Conversion bug with button triggers
0%
History
#1 Updated by Vladimir Tsichevski almost 6 years ago
The trigger, associated with a button is not converted.
The 4gl:
main.p
DEFINE FRAME theFrame
WITH SIZE 30 BY 10.
DEFINE BUTTON applyFormat LABEL "Apply"
TRIGGERS:
ON CHOOSE DO:
MESSAGE "Hello".
END.
END TRIGGERS.
ENABLE applyFormat WITH FRAME theFrame.
VIEW FRAME theFrame.
WAIT-FOR GO OF FRAME theFrame.
The conversion result (no trace of the trigger code):
package com.test3820;
import com.goldencode.p2j.util.*;
import com.test3820.ui.*;
import com.goldencode.p2j.ui.*;
import static com.goldencode.p2j.util.BlockManager.*;
import static com.goldencode.p2j.util.InternalEntry.Type;
import static com.goldencode.p2j.ui.LogicalTerminal.*;
/**
* Business logic (converted to Java from the 4GL source code
* in main.p).
*/
public class Main
{
MainTheframe theframeFrame = GenericFrame.createFrame(MainTheframe.class, "theFrame");
/**
* External procedure (converted to Java from the 4GL source code
* in main.p).
*/
@LegacySignature(type = Type.MAIN, name = "main.p")
public void execute()
{
externalProcedure(Main.this, new Block((Body) () ->
{
theframeFrame.openScope();
FrameElement[] elementList0 = new FrameElement[]
{
new WidgetElement(theframeFrame.widgetApplyFormat())
};
theframeFrame.enable(elementList0);
theframeFrame.view();
LogicalTerminal.waitFor(theframeFrame, new EventList("GO", theframeFrame.asWidget()));
}));
}
}
In OW the 4gl above works as expected: pressing the button prints "Hello".
#2 Updated by Greg Shah almost 6 years ago
I guess this is related to the TRIGGERS phrase which is not as commonly used as the ON statement.
As a workaround, just move the trigger outside of the triggers phrase and into an ON statement.
ON CHOOSE OF applyFormat DO: MESSAGE "Hello". END.
#3 Updated by Vladimir Tsichevski almost 6 years ago
Greg Shah wrote:
I guess this is related to the
TRIGGERSphrase which is not as commonly used as theONstatement.As a workaround, just move the trigger outside of the triggers phrase and into an ON statement.
[...]
Yes, if I rewrite the example as following, it compiles and works as expected:
DEFINE BUTTON applyFormat LABEL "Apply". DEFINE FRAME theFrame applyFormat WITH SIZE 30 BY 10. ON CHOOSE OF applyFormat DO: MESSAGE "Hello". END. ENABLE applyFormat WITH FRAME theFrame. VIEW FRAME theFrame. WAIT-FOR GO OF FRAME theFrame.
#4 Updated by Greg Shah almost 6 years ago
The problem is most likely in rules/annotations/triggers_phrase_rewrite.rules. This code:
<!-- ON phrase for a trigger inside a TRIGGERS block of a CREATE WIDGET/BROWSE
Rewrites
TRIGGERS STATEMENT
ON ON
EVENT_LIST OF
EVENT to EVENT_LIST
TRIGGER_BLOCK EVENT
WIDGET_LIST
VAR_HANDLE
TRIGGER_BLOCK
-->
<rule>relativePath("STATEMENT/CREATE_WIDGET/KW_TRIGGERS/KW_ON") or
relativePath("STATEMENT/CREATE_BROWSE/KW_TRIGGERS/KW_ON")
...
Notice that it only processing for CREATE <widget> and CREATE BROWSE cases. It ignores other cases. Searching for trigger_phrase in progress.g shows that it can be matched in the following other constructs: DEFINE VARIABLE, DEFINE BUTTON, DEFINE RECTANGLE and in the menu item phrase of a DEFINE MENU or DEFINE SUB-MENU.
The solution is to add cases to the above matching logic and to make some modifications to the re-parenting code for the "non-handle" statement cases.
#5 Updated by Greg Shah almost 6 years ago
- Start date deleted (
09/18/2020) - Project changed from Conversion Tools to User Interface