bgracontrols icon indicating copy to clipboard operation
bgracontrols copied to clipboard

BCNumericKeyBoard error compiling after update to 9.0.1.7

Open sstvmaster opened this issue 9 months ago • 36 comments

I got these errors after upgrade bgra component via OPM. BGRABitmap update was OK.

Lazarus stable is used.

Image Image

Rgr Maik

sstvmaster avatar Mar 18 '25 20:03 sstvmaster

Hi, I'm using master not OPM and I can install it with Lazarus 4.0 RC2.

Wich version of lazarus are you using?

lainz avatar Mar 18 '25 23:03 lainz

win32_keybord_error.zip

It raised error under win32. I'm using FPC trunk/Lazarus trunk.

rasberryrabbit avatar Mar 19 '25 01:03 rasberryrabbit

Thanks for reporting the error. Note that as a workaround, you can unchecked problematic units in BGRAControls package:

  • in the package window, select the unit
  • in the panel below, uncheck the two checkboxes

Regards

circular17 avatar Mar 23 '25 06:03 circular17

I think it is related to the @ syntax. Can you try the following fix: remove the @ symbol before PressVirtKey, like this:

      Application.QueueAsyncCall(PressVirtKey, vk_DotNumPad);  

Does it fix all the errors?

circular17 avatar Mar 23 '25 06:03 circular17

Removes "@", it's ok.

rasberryrabbit avatar Mar 23 '25 07:03 rasberryrabbit

I've applied the change in the dev branch.

circular17 avatar Mar 23 '25 07:03 circular17

I just downloaded the dev branch (link) but I'm still getting the same error under macOS/Cocoa. Lazarus/FPC: Lazarus 4.99 (rev main_4_99-1768-gb213e8a294) FPC 3.3.1 aarch64-darwin-cocoa. Both built from trunk yesterday (April 11th 2025 - 3+ weeks after this fix was posted).

Removing the "@" result in: bckeyboard.pas(180,46) Error: Incompatible type for arg no. 1: Got "TBCKeyboard.PressVirtKey(LongInt);", expected "<procedure variable type of procedure(Int64) of object;StdCall>"

Hansaplast avatar Apr 11 '25 09:04 Hansaplast

I commented out the all affected lines only to end up with a linking error "lib Xtst not found" - getting this with the release version and the dev branch version. I see it is a requirement for Linux, but nothing mentioned about macOS (sure hope on a Mac Xtst is not needed).

Note: Running on macOS/Cocoa 15.4. Lazarus 4.99 (rev main_4_99-1771-g8161c5f621) (trunk) FPC 3.3.1 aarch64-darwin-cocoa (trunk)

Hansaplast avatar Apr 12 '25 11:04 Hansaplast

Any solution for MacOS? I am stuck trying to install BGRAControls for Lazarus 3.8.

ovidiopr avatar Apr 14 '25 18:04 ovidiopr

I have replaced the conditionals:

{$IFDEF CPUX86_64}

for:

{$IF DEFINED(CPUX86_64) OR DEFINED(CPUAARCH64)}

Now it seems to pass this part, but then I get the linking error mentioned before: "lib Xtst not found".

Any ideas?

ovidiopr avatar Apr 15 '25 07:04 ovidiopr

I ran into a similar issue. "lib Xtst" does not exist on macOS it seems. 😞

Hansaplast avatar Apr 15 '25 07:04 Hansaplast

I ran into a similar issue. "lib Xtst" does not exist on macOS it seems. 😞

Yes, it does exist. I have installed it with Homebrew (https://formulae.brew.sh/formula/libxtst), but it makes no difference. I still get the same error.

ovidiopr avatar Apr 15 '25 07:04 ovidiopr

Found that one as well, but I'd hate to have to distribute that with my applications (not a "brew" fan when it comes to that) - it would make BGRAControls a no-go for me 😞 I had not tested it though - good thing you did. 😊

Hansaplast avatar Apr 15 '25 07:04 Hansaplast

Hi. Please don't install all the packages with OPM just install bgracontrols.

If that doesn't work please remove all the 'keyboard' controls from the package and try again.

lainz avatar Apr 16 '25 03:04 lainz

Hi. Please don't install all the packages with OPM just install bgracontrols.

If that doesn't work please remove all the 'keyboard' controls from the package and try again.

Thank you for the suggestion, but I get exactly the same result. The package compiles, but the linker gives the error "lib Xtst not found" when rebuilding the IDE.

ovidiopr avatar Apr 16 '25 05:04 ovidiopr

The problem is that you may be installed the mouseandkeyinput package. Remove that package from installation.

lainz avatar Apr 16 '25 18:04 lainz

Did find a directory "mouseandkeyinput", but removing that which caused even more problems.

Hansaplast avatar Apr 17 '25 08:04 Hansaplast

I think there are more components involved like tbcthememanager.

lainz avatar Apr 17 '25 20:04 lainz

Since this seems to affect Lazarus Stable and Trunk, one would expect more users to see this problem? Kind-a doubt this would be macOS specific.

Hansaplast avatar Apr 18 '25 09:04 Hansaplast

Did find a directory "mouseandkeyinput", but removing that which caused even more problems.

If that caused more problems, seems that you're installing some controls that requires that package... do as @circular17 said and remove these from the package.

Also don't install mouseandkeyinput, remove that from the package installation.

lainz avatar Apr 18 '25 15:04 lainz

Go to bgracontrols.lpk > Options > Path > remove mouse and key input.

lainz avatar Apr 18 '25 15:04 lainz

I have tried all the suggestions, but keep getting the same compiler error. Moreover, as soon as I remove bgracontrols I can recompile the IDE without any problem.

ovidiopr avatar Apr 18 '25 22:04 ovidiopr

@circular17 you have macOS right? This issue happens to you in stable or trunk?

I'm on Windows and all it's fine with dev branch...

lainz avatar Apr 18 '25 22:04 lainz

I'm on macOS, and for me it happens with trunk (FPC and Lazarus). I recall seeing OP sstvmaster using stable.

I'll walk you through it, in case I am doing something wrong;

I first open the bgrabitmap (dev) package and compile it. No errors there.

Next I open bgracontrols (dev), remove the path as described by lainz from the path (which leaves only "bgrasvgimagelistform"), and the compile fails as it wants "MouseAndKeyInput" in the bckeyboard unit.

After removing bckeyboard.pas from the Files list (in the package window), it fails again as one or the other unit seems to still us bckeyboard. Deleting the actual bckeyboard file makes "BCDefaultThemeManager" fail as it wants bckeyboard, and the list goes on 😞

Hansaplast avatar Apr 19 '25 07:04 Hansaplast

@circular17 you have macOS right? This issue happens to you in stable or trunk?

I'm on Windows and all it's fine with dev branch...

Yes, the error is in Mac only. I have installed the same version of Lazarus and BGRAComponents in Windows without any issue.

ovidiopr avatar Apr 19 '25 11:04 ovidiopr

Found that one as well, but I'd hate to have to distribute that with my applications (not a "brew" fan when it comes to that) - it would make BGRAControls a no-go for me 😞 I had not tested it though - good thing you did. 😊

Hansaplast, I share your desire not to add another dependency. I am taking your feedback into account. Let's investigate together to understand what's going on with the component. I've tried some patches already but we're not quite there yet.

I have replaced the conditionals:

{$IFDEF CPUX86_64}

for:

{$IF DEFINED(CPUX86_64) OR DEFINED(CPUAARCH64)}

Now it seems to pass this part, but then I get the linking error mentioned before: "lib Xtst not found".

Any ideas?

ovidiopr, thanks for this proposal. The underlying problem is that the callback functions are not defined according to the CPU size:

    procedure PressVirtKey(p: longint);
    procedure PressShiftVirtKey(p: longint); 

It should be instead:

    procedure PressVirtKey(p: PtrInt);
    procedure PressShiftVirtKey(p: PtrInt); 

I've create a branch dev-bckeyboard to experiment changes on this component. I think the code would be easier to understand with some refactoring, namely having directives to choose which way it sends keys. From this code:

    {$IFDEF CPUX86_64}
    Application.ProcessMessages;
    KeyInput.Press(VK_BACK);
    Application.ProcessMessages;
    {$ELSE}
      {$IFDEF FPC}
      Application.QueueAsyncCall(@PressVirtKey, VK_BACK);
      {$ELSE}
      SendKey(VK_BACK);
      {$ENDIF}
    {$ENDIF}  

There seems to be three ways:

  • KeyInput.Press
  • Application.QueueAsyncCall with callback
  • SendKey

circular17 avatar Apr 20 '25 09:04 circular17

@circular17 you have macOS right? This issue happens to you in stable or trunk?

I have macOS with 64-bit Intel CPU, and it compiles without error. Note that I don't use Lazarus/FPC trunk. From the discussion, I gather that some methods use Xtst to simulate keys, and indeed this library has this feature.

Let's try to determine where this happens. The actual methods for simulating input are chosen in MouseAndKeyInput unit:

Image

In my case, it uses the X methods. What does it use in your case?

circular17 avatar Apr 20 '25 10:04 circular17

Hi @circular17,

Thank you very much! I am using the stable version of Lazarus (3.8), and trying to install the stable version of BGRAControls (9.0.1.7). In my case, it uses the same methods.

Image

ovidiopr avatar Apr 20 '25 10:04 ovidiopr

Thanks.

Ok I've updated my version of Lazarus to 3.8 and get the same linking error.

After some investigation into those X functions, I realized that there is a MouseAndKeyInput package included in Lazarus components folder. I presume that the code in BGRAControls was moved there and then updated there but not in BGRAControls.

So I've removed the code from BGRAControls and added a dependency to lazmouseandkeyinput package. Image

That's in dev-bckeyboard branch. Seems to work now on MacOS and Windows. Can you give it a try?

circular17 avatar Apr 20 '25 12:04 circular17

Worked for me when building with x86_64, however it still gives the same error again when cross compiling with AARCH64. Same error in bckeyboard.pas. I used the dev-bckeyboard branch. Should I remove something?

p.s. clean install, wiped everything this morning and rebuild FPC and Lazarus IDE for x86_64, and cross compiler for AARCH64. I would prefer the other way around but for some reason FPCUpDeluxe keeps crashing when building FPC for AARCH64 (not BGRAControls related).

Hansaplast avatar Apr 20 '25 13:04 Hansaplast