Recent

Author Topic: (SOLVED) mouseandkeyinput help  (Read 1952 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
(SOLVED) mouseandkeyinput help
« on: December 12, 2019, 10:03:23 pm »
Hi guys. I'm modifying the mouseandkeyinput package to make it work with cocoa. Mouse management seems to work, but I have a question. If you look at the CocoaMouseInput.pas source
 you will see the commented line

// CFRelease (MyMouseEvent);

Because I couldn't find the equivalent in FPC sources. Does anyone know how to work around this problem?

Instead the keyboard management does not work. If you look at the CocoaKeyInput.pas source you will see that the SendKeyInput function is the offending part. To understand the problem just fill in my example with the modified package that I release here and press the button called test 2. You will see that instead of writing W LAZARUS writes other characters. Ideas ?!
« Last Edit: December 18, 2019, 10:24:14 pm by xinyiman »
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: mouseandkeyinput help
« Reply #1 on: December 12, 2019, 10:43:40 pm »
If that really isn't declared in any of the existing interface units you might need to try to roll your own, and to raise the issue on Mantis so that the relevant maintainer is aware.

However, having been working with code of a similar form recently  I have to ask: is it safe to release that object before the posted message has been dispatched and its parameters consumed?

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: mouseandkeyinput help
« Reply #2 on: December 16, 2019, 08:16:52 am »
I wrote on mantis and was told that I have to ask here on the forum.

https://bugs.freepascal.org/view.php?id=36433
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: mouseandkeyinput help
« Reply #3 on: December 18, 2019, 08:29:17 pm »
you probably don't want to use CGEvents for Cocoa implementation.
Instead you might want to try NSEvent API.
There are two constructors you need to utilize: keyEventWithType... and mouseEventWithType...
These two should be enough to synthesize input for keyboard and mouse respectivly.

I think Tom left the community quite awhile ago (over 10 years ago). So, you might not hear back from him any time soon. Would you like to become the new maintainer?
« Last Edit: December 18, 2019, 08:35:30 pm by skalogryz »

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

 

TinyPortal © 2005-2018