Recent

Author Topic: A fix causes double spaces.  (Read 970 times)

dbannon

  • Hero Member
  • *****
  • Posts: 3348
    • tomboy-ng, a rewrite of the classic Tomboy
A fix causes double spaces.
« on: April 23, 2025, 05:52:16 am »
I am hoping that rich2014 might see this. It relates to a commit to Lazarus,
https://gitlab.com/freepascal.org/lazarus/lazarus/-/commit/d0fda807914d090fa11f910000d1a23794e2e7fe

that made two small changes. One of them, applied to cocoaprivate.pas but now moved to cocoacustomcontrols.pas #325, in procedure TCocoaCustomControlWithBaseInputClient.keyDown(theEvent: NSEvent); causes my application to generate double spaces every time the space bar is hit.  My app uses KMemo, available from OSM and works fine in Linux and Windows and worked fine on MacOS until this fix was applied.

I have patched my lazarus to restore the keyDown() procedure and everything now works fine. However, I do not understand what the original fix was addressing so cannot for test it. Commit says "Cocoa: Fix the issue that the Space key on the Button does not work" but does not mention a bug report with any details of what that means.

rich2014, can you remember what this was about ?

I can very easily generate a test project but you would need to install KControls (eg from OSM).

Davo

Code: Pascal  [Select][+][-]
  1. procedure TCocoaCustomControlWithBaseInputClient.keyDown(theEvent: NSEvent);
  2. var
  3.   textView: NSView;
  4.   isFirst: Boolean;
  5. begin
  6.   if (not _inIME) and (theEvent.keyCode in
  7. //     [kVK_Return, kVK_ANSI_KeypadEnter, kVK_Escape, kVK_Space]) then
  8.       [kVK_Return, kVK_ANSI_KeypadEnter, kVK_Escape]) then     // DRB removed kVK_Space,  fixes  double  spac  issue
  9.   begin
  10.     inherited;
  11.     exit;
  12.   end;
  13.   ....


 refs-


edit: correct commit url
« Last Edit: April 23, 2025, 05:55:36 am by dbannon »
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

rich2014

  • New Member
  • *
  • Posts: 22
Re: A fix causes double spaces.
« Reply #1 on: May 03, 2025, 02:12:08 am »
@dbannon, hi,

1. does the problem of two spaces only occur in KMemo?

2. will the RETURN also be repeated twice?

rich2014

  • New Member
  • *
  • Posts: 22
Re: A fix causes double spaces.
« Reply #2 on: May 03, 2025, 02:32:57 am »
@dbannon, hi,

i installed KControls 1.7.3 via OPM.

then in a new project, I added only one KMemo control.

the spacebar is working fine.

FPC 3.2.2, Lazarus Main Trunk, AArch64.

can you provide a minimal project that reproduces the problem?

dbannon

  • Hero Member
  • *****
  • Posts: 3348
    • tomboy-ng, a rewrite of the classic Tomboy
Re: A fix causes double spaces.
« Reply #3 on: May 03, 2025, 10:18:18 am »
Thanks for following up Rich, yep, can do a project, easy. But sounds like you have already do so, thats all it needs !

It shows up on my Intel Mac is running Monteray and I'm using FPC3.2.4branch. And, of course, so is my end users who reported the problem, I make their binaries.  So, is the common factor FPC ???  (I doubt it).

I'll fire up my Mac tomorrow and try with FPC3.2.2 and see if that makes a difference. Hmm, I am also using a newer KControls than in OPM, I'll test that too.

Will get back to you !

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

dbannon

  • Hero Member
  • *****
  • Posts: 3348
    • tomboy-ng, a rewrite of the classic Tomboy
Re: A fix causes double spaces.
« Reply #4 on: May 05, 2025, 01:52:53 pm »
OK, I'm back !

Rich, I am using an Intel MacMini running Monteray. I have tried with FPC322 and FPC324, Lazarus 04rc3 and a fresh (today) main. I have tried with the KControls from OPM and the more current one I use.

Sigh, in every case I see two spaces for each press of the space bar in the KMemo.

I did not initially notice the problem (and pushed out a release) because the particular font I was using has quite a narrow space and the double space looked, to me, like just a particularly wide one. Are you sure you are not falling for the same trap ?

Otherwise, I don't know what to suggest ?  I see it and I've had three bug reports from users.  I have attached a demo project but I bet its no different from yours.  :)

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

rich2014

  • New Member
  • *
  • Posts: 22
Re: A fix causes double spaces.
« Reply #5 on: May 09, 2025, 04:07:59 pm »
fixed in Main Trunk (0415835) and fixes_4.

test it please.

dbannon

  • Hero Member
  • *****
  • Posts: 3348
    • tomboy-ng, a rewrite of the classic Tomboy
Re: A fix causes double spaces.
« Reply #6 on: May 11, 2025, 04:20:49 am »
Great Rich, I'll try and do that test this evening !

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

dbannon

  • Hero Member
  • *****
  • Posts: 3348
    • tomboy-ng, a rewrite of the classic Tomboy
Re: A fix causes double spaces.
« Reply #7 on: May 11, 2025, 02:10:33 pm »
Yep, that has fixed my problem. I have tested on main, all good. I was not sure what your original fix was addressing so have not tested for that, just my problem.

Thanks Rich, excellent result. I'll use Fixes_4 for my next release.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018