Lazarus

Programming => Widgetset => Cocoa => Topic started by: xinyiman on December 12, 2019, 10:03:23 pm

Title: (SOLVED) mouseandkeyinput help
Post by: xinyiman 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 ?!
Title: Re: mouseandkeyinput help
Post by: MarkMLl 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
Title: Re: mouseandkeyinput help
Post by: xinyiman 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
Title: Re: mouseandkeyinput help
Post by: skalogryz 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 (https://developer.apple.com/documentation/appkit/nsevent?language=objc) 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?
Title: Re: mouseandkeyinput help
Post by: xinyiman on December 18, 2019, 10:23:58 pm
https://forum.lazarus.freepascal.org/index.php/topic,47830.msg343398/topicseen.html#new
TinyPortal © 2005-2018