Bug #9929
FILL-IN: Incorrect APPLY statement behavior
100%
History
#1 Updated by Vladimir Tsichevski about 1 year ago
In OE, the APPLY statement enables programmatic simulation of user input by sending events to widgets, facilitating automated testing. For instance, APPLY can be used to programmatically insert values into a FILL-IN widget.
The 4GL demo program below defines two FILL-IN widgets: one bound to a DATE data type and another to a CHARACTER data type. A series of APPLY statements sends the characters "1234" to each FILL-IN.
In OE, the resulting values are "12-34-" for the date FILL-IN (formatted as "99-99-9999") and "1234" for the character FILL-IN, as expected. In FWD, the values are incorrectly "4 - -" for the date FILL-IN and "4321" for the character FILL-IN.
DEFINE VARIABLE dateField AS DATE FORMAT "99-99-9999" VIEW-AS FILL-IN NO-UNDO. DEFINE VARIABLE characterField AS CHARACTER FORMAT "x(50)" VIEW-AS FILL-IN NO-UNDO. DEFINE FRAME f dateField NO-LABEL SKIP characterField NO-LABEL. ENABLE ALL WITH FRAME f. APPLY "1" TO dateField. APPLY "2" TO dateField. APPLY "3" TO dateField. APPLY "4" TO dateField. APPLY "1" TO characterField. APPLY "2" TO characterField. APPLY "3" TO characterField. APPLY "4" TO characterField. WAIT-FOR WINDOW-CLOSE OF FRAME f.
#2 Updated by Vladimir Tsichevski about 1 year ago
- Assignee set to Vladimir Tsichevski
Problem origin
In FWD, the processing of keyboard events for FILL-IN widgets depends on whether the containing window is focused. When the window lacks focus, the FILL-IN caret is forcibly set to the leftmost or rightmost position, based on the widget’s alignment. This adjustment occurs both before and after event processing, overriding any caret position changes made during the event. Consequently, programmatic inputs, such as those sent via APPLY before the WAIT-FOR loop (when the window is unfocused), lose their intended caret positioning.
This behavior aligns with OE character mode but is incorrect for GUI mode, where caret positions should persist as set by event processing.
The problematic code, located in FillIn (line 1548), has existed since revision 10115 (committed by Constantin in pre-GUI era) and was not updated for GUI mode.
// apply char without moving cursor
if (isRightAlignedInt())
config.appDataPres.moveCursorEnd();
else
config.appDataPres.moveCursorBegin();
...
boolean input = config.appDataPres.input(ch);
...
if (isRightAlignedInt())
config.appDataPres.moveCursorEnd();
else
config.appDataPres.moveCursorBegin();
The issue stems from FWD’s event handling for FILL-IN widgets:
- In GUI mode,
FillInGuiImpl’sprocessKeyEventmethod performs pre- and post-processing around the superclassFillIn’sprocessKeyEventmethod, providing flexibility for GUI-specific behavior. - In ChUI mode, only
FillIn’sprocessKeyEventmethod is used, handling both ChUI and GUI logic. This makes the method overly complex and prone to errors, as it lacks mode-specific separation. - The ChUI-specific
FillInImpldoes not overrideprocessKeyEvent, leaving no dedicated place for ChUI-only logic.
Proposed Solution
To resolve this, introduce an overridden processKeyEvent method in FillInImpl for ChUI-specific logic, moving the caret adjustment code there. This ensures:
FillIn’sprocessKeyEventhandles shared logic only.FillInImpl’sprocessKeyEventmanages ChUI-specific behavior, like caret positioning when the window is unfocused.FillInGuiImplcontinues to handle GUI-specific pre- and post-processing.
Note: The proposed fix was also implemented while resolving #9913, overriding processKeyEvent in FillInImpl to handle ChUI-specific logic.
#3 Updated by Vladimir Tsichevski about 1 year ago
- Status changed from New to WIP
#4 Updated by Vladimir Tsichevski about 1 year ago
I analyzed the processKeyEvent method implementations in FillIn and FillInGuiImpl to see if I could split the code between FillIn, FillInImpl, and FillInGuiImpl. The code in the FillIn class is pretty complicated, so splitting it might involve too much work right now - like doing full testing and documenting how FILL-IN s behave in OE, which is a big task by itself.
Instead, I decided to solve the original issue by applying a small patch first.
#5 Updated by Vladimir Tsichevski about 1 year ago
- Status changed from WIP to Review
- % Done changed from 0 to 100
The issue was fixed in 9929a, revision 15877. Now, printable keyboard characters sent using the APPLY are processed "naturally" in GUI, while the quirk described in #9929-2 persists in ChUI mode, matching OE behavior.
#6 Updated by Hynek Cihlar about 1 year ago
- Status changed from Review to Internal Test
Code review 9929a.
The changes look OK to me. Kudos for keeping the changes to the bare minimum :-).
Please go ahead with regression testing, also include ChUI regression tests.
#7 Updated by Vladimir Tsichevski about 1 year ago
Hynek Cihlar wrote:
Code review 9929a.
The changes look OK to me. Kudos for keeping the changes to the bare minimum :-).
Please go ahead with regression testing, also include ChUI regression tests.
As usual, I am asking someone to run our ChUI testing framework for me, since I could not run it on my workstation.
#8 Updated by Hynek Cihlar about 1 year ago
Vladimir Tsichevski wrote:
As usual, I am asking someone to run our ChUI testing framework for me, since I could not run it on my workstation.
I'll run it.
#9 Updated by Hynek Cihlar about 1 year ago
ChUI regression tests passed.
#10 Updated by Vladimir Tsichevski about 1 year ago
Hynek Cihlar wrote:
Code review 9929a.
The changes look OK to me. Kudos for keeping the changes to the bare minimum :-).
Please go ahead with regression testing, also include ChUI regression tests.
Done testing with two big customers applications.
I think, we can merge now.
#11 Updated by Greg Shah about 1 year ago
- Status changed from Internal Test to Merge Pending
You can merge to trunk now.
#12 Updated by Vladimir Tsichevski about 1 year ago
Greg Shah wrote:
You can merge to trunk now.
Done. Revno is 15938.
#13 Updated by Greg Shah about 1 year ago
- Status changed from Merge Pending to Test
#15 Updated by Hynek Cihlar 10 months ago
- Status changed from Test to Closed
Vladimir Tsichevski wrote:
Can this be closed?
Yes.