Recent

Author Topic: (Solve by myself) MacOSX on M1 , IME input on Chinese character  (Read 1534 times)

powerpcer

  • Jr. Member
  • **
  • Posts: 93
(Solve by myself) MacOSX on M1 , IME input on Chinese character
« on: September 10, 2022, 12:42:17 pm »
MACOSX OnUTF8KeyPress for IME input does not work correctly.
If the IME input requires 3 keys, return the word corresponding to each key (so up 3 times),
but not the last word.
i am using the OS bundled Chinese input Method.

refer to attachment
« Last Edit: September 19, 2022, 04:25:25 pm by powerpcer »

powerpcer

  • Jr. Member
  • **
  • Posts: 93
Re: MacOSX on M1 , IME input on Chinese character
« Reply #1 on: September 10, 2022, 06:05:47 pm »
it seems all input on MacOS 12.5.1 will fire UTF8Keypress.
so, how to setup and let me debug the source in LCL/interfaces/cocoa?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8620
  • Debugger - SynEdit - and more
    • wiki
Re: MacOSX on M1 , IME input on Chinese character
« Reply #2 on: September 10, 2022, 06:16:21 pm »
so, how to setup and let me debug the source in LCL/interfaces/cocoa?

1) Compile the IDE with debug info. Menu Tools > configure build IDE.  Add custom option: -gw3
  Build, and restart
2) Open Project: ide/lazarus.lpi
3) Run / F9


powerpcer

  • Jr. Member
  • **
  • Posts: 93
Re: MacOSX on M1 , IME input on Chinese character
« Reply #3 on: September 11, 2022, 05:53:21 am »
after that, i got
Code: Pascal  [Select][+][-]
  1. error: lazarus debug map object file '/Users/terrylou/Lazarus/lazarus/lcl/units/aarch64-darwin/cocoa/interfaces.o' has changed (actual time is 2022-09-11 11:32:33.000000000, debug map time is 2022-09-11 07:42:26.000000000) since this executable was linked, file will be ignored
  2.  

and click "OK" to continue debugging, but the debugger never work.

powerpcer

  • Jr. Member
  • **
  • Posts: 93
Re: MacOSX on M1 , IME input on Chinese character
« Reply #4 on: September 11, 2022, 05:59:39 am »
when i clean up and build, it shows
Code: Pascal  [Select][+][-]
  1. The project's compiler options has no compile command.
  2. See Project / Compiler Options ... / Compilation
what command do i need to add?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8620
  • Debugger - SynEdit - and more
    • wiki
Re: MacOSX on M1 , IME input on Chinese character
« Reply #5 on: September 11, 2022, 12:22:16 pm »
when i clean up and build, it shows
Code: Pascal  [Select][+][-]
  1. The project's compiler options has no compile command.
  2. See Project / Compiler Options ... / Compilation
what command do i need to add?

None, whenever you change something, you need to build via menu Tools > Build Lazarus.

Make no changes after that => the moment that F9 thinks that you changed something it will recompile individual files. But NOT recreate the executable => and then you get that error "object file.. .changed..."


If you keep getting that error, go to Tools > Configure Build Lazarus
and add to custom options:
-Xg


This will create a folder lazarus.dsym or lazarus.app.dsym.
Should you ever remove the -Xg, then you need to deleted that folder too.


Sorry it's a while since I done this on a Mac. Hence the "if" ad "try".


powerpcer

  • Jr. Member
  • **
  • Posts: 93
Re: MacOSX on M1 , IME input on Chinese character
« Reply #6 on: September 11, 2022, 04:47:35 pm »
thanks Martin,
 i found that KeyEvPrepare in cocoawscommon.pas will fire on every key press.
this catch every CJK char that i typed, but not the last.
the strange is, the IME input dialog not appear.  that different from others APPs
where can i check?


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8620
  • Debugger - SynEdit - and more
    • wiki
Re: MacOSX on M1 , IME input on Chinese character
« Reply #7 on: September 11, 2022, 04:56:07 pm »
Unfortunately my expertise is the Debugger.
I am not familiar with the Mac specific LCL/widgetset code.

So someone else has to answer this.

Since the amount of Mac users/devs (compared to other OS) is lower: if no-one answers here, I suggest to post a copy on the mail list (and/or additionally open an issue report on the bug tracker, since this seems to qualify as bug).

powerpcer

  • Jr. Member
  • **
  • Posts: 93
Re: MacOSX on M1 , IME input on Chinese character
« Reply #8 on: September 11, 2022, 06:13:26 pm »
ok, thanks.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8620
  • Debugger - SynEdit - and more
    • wiki
Re: MacOSX on M1 , IME input on Chinese character
« Reply #9 on: September 11, 2022, 06:34:45 pm »
Just remembered, may be important: Add info which controls are affected.

That is either
- TEdit, TMemo, TComboBox
- TSynEdit (IDE Source editor), maybe TRichEdit
- both groups

The first are OS controls, the latter are custom controls.

---
EDIT:

I peaked at your attached project, and you are checking keystrokes in the form.
I have no idea how an IME deals with that after all there is no input element (even though the form can receive keystrokes.)

Testing on Windows, it is possible for an IME to open on a plain TForm.
However it seems to depend on some settings. The main page of the IDE's "About dialog" does not (on Win) allow to open an IME.
« Last Edit: September 11, 2022, 06:42:46 pm by Martin_fr »

powerpcer

  • Jr. Member
  • **
  • Posts: 93
Re: MacOSX on M1 , IME input on Chinese character
« Reply #10 on: September 12, 2022, 06:36:38 am »
on Windows 10, UTF8KeyPress works correctly as its description.

powerpcer

  • Jr. Member
  • **
  • Posts: 93
Re: MacOSX on M1 , IME input on Chinese character
« Reply #11 on: September 17, 2022, 02:50:40 pm »
how can i make packages of cocoaint only?
i got fpcsrc and  fpcsrc/packages/cocoaint,
but i need to rebuild it only.
how could i build this package only?
when i type fpcmake on fpcsrc/packages/cocoaint/
it shows me:
Processing Makefile.fpc
 aarch64-darwin requires: rtl,paszlib,fcl-process,hash,libtar,fpmkunit
 Writing Makefile


AlexTP

  • Hero Member
  • *****
  • Posts: 2002
    • UVviewsoft

powerpcer

  • Jr. Member
  • **
  • Posts: 93
Re: MacOSX on M1 , IME input on Chinese character
« Reply #13 on: September 17, 2022, 04:56:04 pm »
that's different with your behavior.
and i just want to know how to compile package only.
if you know it, just tell me.
« Last Edit: September 17, 2022, 04:57:43 pm by powerpcer »

powerpcer

  • Jr. Member
  • **
  • Posts: 93
Re: MacOSX on M1 , IME input on Chinese character
« Reply #14 on: September 19, 2022, 05:13:13 am »
after some investigate,
NSTextInputClient.inc==>NSTextInputClientProtocol -->CocoaUtils.inc==>TCocoaInputClient
on TCocoaInputClient, the only validAttributesForMarkedText was fired on debugger.
but not the rest function/procedure.
In Objective-C/SWIFT, the NSTextInputClient method sequence
validAttributesForMarkedText x 3
selectedRange x 2
attributedSubstringforProposedRange x 1
selectedRange x 1
hasMarkedText x 1
validAttributesForMarkedText x 5
setMarkedText  x 1    --> now APP got the character send from IME

but now, only first validAttributesForMarkedText

 

TinyPortal © 2005-2018