kryslt / KControls

Free components for Delphi and Lazarus, this is the main repository maintained by the original author.
BSD 3-Clause Clear License
59 stars 32 forks source link

KGridDemo example - "TEdit" field shrinks text (other fields too) #65

Closed Modzho closed 1 month ago

Modzho commented 1 month ago

KGridDemo example - "TEdit" field shrinks text (other fields too) Video: https://youtu.be/mI2fLqi2myA

Tested: KGrid 1.7.3 Lazarus 3.6 OS: Win7HP SP1

and Lazarus 2.2.6 Typhon 8.1 OS: W11Pro 23H2

KGrid is unusable???

kryslt commented 1 month ago

Cannot reproduce.

Tested with: KControls master (KGridDemo example). Lazarus 3.99 (rev main_3_99-1341-gad54dc2ceb) FPC 3.2.2 x86_64-win64-win32/win64 OS Win11Home 23H2 22631.4317 CZ localization.

Your source code must either be changed or there is some weird OS limitation.

Modzho commented 1 month ago

Thank You for quick response! Maybe this is only on my pc.

Modzho commented 1 month ago

https://mega.nz/file/zjJ2GKoB#PoqBx3I9zukT9yCxWy61ASpIpH5SVe2bhxg8KT1aVdM My exe file for testing.

kryslt commented 1 month ago

Nope. No problem on my PC. You have some crazy Win setting or is it Lazarus bug. Which Win locale? Try default English locale, Linux/MAC etc.

Modzho commented 1 month ago

Locale: English (United States). It looks like there is something wrong in my pc. I will search for it tomorrow.

kryslt commented 1 month ago

You can also trace the problem using the debugger. a. Set text from TKGrid to TEdit: TForm1.KGrid1EditorDataFromGrid - line SetControlText(AEditor, S); b. Set text from TEdit to TKGrid: TForm1.KGrid1EditorDataToGrid - line S := GetControlText(AEditor); Both texts in S variable must equal if no editing in TEdit has been done. You can also debug further down to the widget set level, but this assumes a good knowledge of LCL and the WinAPI widget set.

Modzho commented 1 month ago

Screrenshot 2024-10-10 093218

I don't understand all the logic, but for '1 000 000' editor input procedure KGrid1EditorDataToGrid line 834: ParseText(S, S1, Value); line 834: returns with S = '1 000 000', but S1 = '1 000' and value = '0'

and in line 837 Cell.Text := S1; assigns it (S1) to Cell(?)

for 'item 14' as input line 834: returns with S = 'item 14' S1 = 'item' and value = '14'

procedure ParseText is small procedure at line 188 that returns TextPart and NumberPart of TKString. I don't need any parts :)). So KGrid is working fine and the problem is in KGrid example.

As quick and dirty workaround I edited it: //ParseText(S, S1, Value); S1 := S; Value := 0;

kryslt commented 1 month ago

Yep, you are right. This is a small problem in the KGrid example. I haven't tried the 'right' way to reproduce the issue on my computer until now. The problem is obvious and will be fixed.

kryslt commented 1 month ago

One more note; For '1 000 000' editor input the result is '1 000' and this is correct. This is how the demo should behave. We just demonstrate custom cell class with text and number part. If you input '1 000 001' the result is '1 000 1' etc.

Modzho commented 1 month ago

I can confirm that bug is fixed. Now KGridDemo works as expected!