Skip to content

Remove LazMouseAndKeyInput dependency (GPL licence) and use LCLIntf (…#266

Merged
circular17 merged 6 commits into
bgrabitmap:dev-bgracontrolsfrom
fredvs:master
Mar 27, 2026
Merged

Remove LazMouseAndKeyInput dependency (GPL licence) and use LCLIntf (…#266
circular17 merged 6 commits into
bgrabitmap:dev-bgracontrolsfrom
fredvs:master

Conversation

@fredvs

@fredvs fredvs commented Mar 6, 2026

Copy link
Copy Markdown
Member

…LGPL licence).

dependabot Bot and others added 5 commits September 1, 2025 22:33
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
…ctions/actions/checkout-5

Bump actions/checkout from 4 to 5
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
…ctions/actions/checkout-6

Bump actions/checkout from 5 to 6
@zoran-vucenovic

Copy link
Copy Markdown

Hello, Fred, please also remove the dependency from the package (the .lpk file).

@circular17
circular17 changed the base branch from master to dev-bgracontrols March 27, 2026 13:22
@circular17

Copy link
Copy Markdown
Contributor

Seems a reasonable change to me.

Note I changed the target branch to dev-bgracontrols.

@circular17
circular17 merged commit a055faf into bgrabitmap:dev-bgracontrols Mar 27, 2026
1 check passed
@circular17

Copy link
Copy Markdown
Contributor

Hmm I tested it on Windows and it doesn't seem to send the letters to the Edit in the test program. Maybe we need as well to send the KEYPRESS event?

@fredvs

fredvs commented Mar 28, 2026

Copy link
Copy Markdown
Member Author

What test program are you using?

@fredvs

fredvs commented Mar 28, 2026

Copy link
Copy Markdown
Member Author

@circular17 : Yep our best friend gemini propose your solution too:

procedure TBCKeyboard.PressVirtKey(p: PtrInt);
var
Target: TWinControl;
begin
Target := Screen.ActiveControl;
if (Target = nil) or not Target.CanFocus then Exit;

// 1. Signal key is pressed
LCLIntf.SendMessage(Target.Handle, LM_KEYDOWN, p, 0);

// 2. IMPORTANT: Send the character message so text appears
// Use LM_CHAR or LM_KEYPRESS (internal LCL equivalent)
LCLIntf.SendMessage(Target.Handle, LM_CHAR, p, 0);

// 3. Signal key is released
LCLIntf.SendMessage(Target.Handle, LM_KEYUP, p, 0);
end;

@fredvs

fredvs commented Mar 28, 2026

Copy link
Copy Markdown
Member Author

OK I did test test_bckeyboard on Linux with original unit BCKeyboard; who uses MouseAndKeyInput.

And it does not work too. ;(

But adding KeyInput.press:

procedure TBCKeyboard.PressVirtKey(p: PtrInt);
begin
  KeyInput.Down(p);
  KeyInput.press(p);  // adding this
  KeyInput.Up(p);
end;

It works!

Then doing the same but using LCLIntf vs MouseAndKeyInput

This works (and gemini was not perfectly ok, LM_CHAR must be last):

procedure TBCKeyboard.PressVirtKey(p: PtrInt);
var
  Target: TWinControl;
begin
Target := Screen.ActiveControl;
if (Target = nil) or not Target.CanFocus then Exit;
LCLIntf.SendMessage(Target.Handle, LM_KEYDOWN, p, 0);
LCLIntf.SendMessage(Target.Handle, LM_KEYUP, p, 0);
LCLIntf.SendMessage(Target.Handle, LM_CHAR, p, 0);  // must be last
end;  

For PressShiftVirtKey, LM_CHAR is not needed, this is ok:

procedure TBCKeyboard.PressShiftVirtKey(p: PtrInt);
var
  Target: TWinControl;
begin
  Target := Screen.ActiveControl;
   if Target = nil then Exit;

   LCLIntf.SendMessage(Target.Handle, LM_KEYDOWN, VK_SHIFT, 1);
   LCLIntf.SendMessage(Target.Handle, LM_KEYDOWN, p, 1);
   LCLIntf.SendMessage(Target.Handle, LM_KEYUP, p, 1);
   LCLIntf.SendMessage(Target.Handle, LM_KEYUP, VK_SHIFT, 1);
end;   

@fredvs

fredvs commented Mar 28, 2026

Copy link
Copy Markdown
Member Author

Ooops, no it is not working using LCLIntf and LM_CHAR, sorry.

I continue to investigate.

@fredvs

fredvs commented Mar 28, 2026

Copy link
Copy Markdown
Member Author

No I am totally lost even using original code unit BCKeyboard; who uses MouseAndKeyInput
and adding KeyInput.press:

procedure TBCKeyboard.PressVirtKey(p: PtrInt);
begin
  KeyInput.Down(p);
  KeyInput.press(p);  // adding this
  KeyInput.Up(p);
end;

It does NOT works. (I dont know why I was thinking it worked).

@fredvs

fredvs commented Mar 28, 2026

Copy link
Copy Markdown
Member Author

I think that maybe the problem is because when you click on a button/key Edit1 loose focus and so the char is not added.
I did not find how to set CanFocus := False for the buttons/keys.

But it is only a "maybe" so sorry for the lot of noise.

@circular17

Copy link
Copy Markdown
Contributor

I guess I found something that works on Windows and Linux with some tweaks. Let's continue the discussion in the new pull request: #267

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants