Bug #11170
The caret position is initially wrong for DECIMAL/INTEGER FILL-IN widgets
100%
History
#1 Updated by Delia Mitric 6 months ago
This is a simple testcase:
DEFINE VARIABLE l AS DECIMAL NO-UNDO. DEFINE FRAME f l NO-LABEL. ENABLE ALL WITH FRAME f. MESSAGE LENGTH(l:SCREEN-VALUE). WAIT-FOR WINDOW-CLOSE OF FRAME f.
In OE: the cursor position is initially 0
In FWD: the cursor position is initially > 0
#3 Updated by Delia Mitric 4 months ago
The initial cursor position for DECIMAL FILL-IN is 8 because of the screen.length() value which is 9.
When the execution reaches the initClear method, the screen contains this text: " 0.00".
Initially, the screen shouldn't contain any string until the user introduce a number into the fill-in or deletes its content. Even if the screen value is known as " 0.00", no value is displayed. This affects just the cursor position.
#6 Updated by Hynek Cihlar 4 months ago
- Status changed from Review to WIP
- % Done changed from 100 to 90
Code review 11170.
ThinClientdependency creates layer violation, NPE risk, and inconsistency: ThegetInitialCursorPosmethod introduces a dependency onThinClient.getInstance().isChui()that has multiple critical issues:- Layer violation: The format package (
ui.client.format) is a lower-level layer than the CHUI client layer (ui.chui), and upward dependencies break the existing architecture. - NPE in batch/headless contexts:
ThinClient.getInstance()returnsnullwhen noThinClientis bound to the current thread (e.g., inBatchDrivermode or server-side code paths). The unconditional call will throw aNullPointerExceptionin these contexts. - Inconsistency with existing patterns: The entire file uses
Utils.isChUI()for CHUI detection at lines 411, 1141, 1349, and 1377. IntroducingThinClientcreates a style inconsistency. - Solution: Check whether
isCharInterface()(inherited fromDisplayFormat) can be used in this case. Consider the other execution modes - batch and redirected streams.
- Layer violation: The format package (
Can the block
if (firstInitClear)
{
invalidateScreen();
screenBuf = new StringBuilder("");
firstInitClear = false;
return;
}
be moved to init() method and firstInitClear removed?
#8 Updated by Delia Mitric 4 months ago
Hynek Cihlar wrote:
Code review 11170.
Consider the other execution modes - batch and redirected streams.
Hynek, please explain what do you mean by batch and redirected streams execution modes in this context? How should I check also these execution modes for a NumberFormat FILL-IN?
#9 Updated by Razvan-Nicolae Chichirau 2 months ago
- Assignee changed from Delia Mitric to Razvan-Nicolae Chichirau
#10 Updated by Razvan-Nicolae Chichirau 2 months ago
CLEAR() method), the following hold:
- The widget screen value is empty, regardless of the format.
- If any valid input is passed to a
NumberBufinstance, then the updated value will be displayed.
Tested on GUI + ChUI.
For example, suppose a decimal fill-in. Upon initialization, the 4GL screen-value internally is 0.00, but the shown value is empty. When a user inputs the character 2, then 0.00 should be considered for input validation purposes. In the end, as the character is valid for the current presentation, the updated value will be displayed (i.e, 2.00).
As such, Delia's approach seems wrong, as the presentation should display blanks on every clear call, not just on the first one.
- Store an
emptyModeflag inNumberBuf. The default value is false, and on any.clear()call this will be enabled, and disabled again on any valid input. In this mode, the reported screen value will be empty. Methods such as setting the cursor on the first/last position will set the cursor on the 0 position. Methods such as moving cursors to left or right will be a NO-OP. - Implement
EmptyPresentationwhich should act as a wrapper over another presentation. The delegate can control this wrapper through a function which tells if the empty mode should be enabled. In this way, we can decouple the empty presentation logic from the actual implementation.
#11 Updated by Razvan-Nicolae Chichirau 2 months ago
- Successfully implemented the first idea from #11170-10. The second one was bringing too much overhead for essentially a binary problem: should the presentation act like an empty presentation or not?
- Initially the solution was for both ChUI and GUI, but testing showed this empty mode (where screen value is empty, cursor can not be moved in either direction) is only true for GUI based interfaces. As such, my solution will touch only GUI.
- The final idea (most probably) of the changes will be as follows:
- Keep 2 states for a GUI number presentation, private and public.
- When the empty mode is enabled, external callers of this presentation will see it just as an empty one. Cursor position is always 0, screen value is always the empty string.
- Internal callers, such as methods working with inputs will see the "real" presentation state: the screen value is actually the default value for that data-type and the cursor position is aligned accordingly.
#12 Updated by Razvan-Nicolae Chichirau 2 months ago
- Status changed from WIP to Review
- % Done changed from 90 to 100
Hynek: Please review 11170a/rev. 16564.
#13 Updated by Hynek Cihlar about 2 months ago
- % Done changed from 100 to 90
- Status changed from Review to WIP
Code review 11170a revisions 16561..16564
- [MINOR] style
NumberBufGui.deleteRegion: Javadoc@paramtags lack spacing padding —@param startand@param endshould be@param start/@param end, and description continuation lines should align to match, consistent with the rest of the file. - [MINOR] style
NumberBuf.receiveInput: Javadoc@returntag uses two spaces (@return) instead of the standard three spaces (@return) used throughout the file. - [MINOR] style
NumberBufGui.input: Javadoc@param chdescription "Input character" is missing a trailing period, inconsistent with the same description inNumberBuf.input("Input character.").
Otherwise the changes look good.
#14 Updated by Razvan-Nicolae Chichirau about 2 months ago
- Status changed from WIP to Review
- % Done changed from 90 to 100
Please check rev. 16565.
#15 Updated by Hynek Cihlar about 2 months ago
- Status changed from Review to Internal Test
Razvan-Nicolae Chichirau wrote:
Please check rev. 16565.
It's good, please go ahead with regression testing. ChUI regression tests will be needed, too.
#16 Updated by Razvan-Nicolae Chichirau 27 days ago
- ChUI regression tests
- fill-in, text and combo-box tests from testcases
- Hotel GUI + 2 customer app smoke-tests
- Unit-tests from another customer
If this is enough, 11170a should be merged.
#17 Updated by Radu Apetrii 27 days ago
- Status changed from Internal Test to Merge Pending
Seems good. 11170a can be merged right now.
#18 Updated by Razvan-Nicolae Chichirau 27 days ago
- Status changed from Merge Pending to Test
Branch 11170a was merged into trunk as rev. 16614 and archived.