このソリューションはCocoaフレームワークを使用しています。ココアは推奨されておらず、私は他の代替ソリューションを知らない。しかし、以下は魅力のように動作します。
最後に、私はフレームワークを使用して解決策を見つけました。ここに私が必要とする呼び出しを定義する私のMCarbon
インターフェイスがあります。
public interface MCarbon extends Library {
MCarbon INSTANCE = (MCarbon) Native.loadLibrary("Carbon", MCarbon.class);
Pointer GetCurrentEventQueue();
int SendEventToEventTarget(Pointer inEvent, Pointer intarget);
int RemoveEventFromQueue(Pointer inQueue, Pointer inEvent);
void ReleaseEvent(Pointer inEvent);
Pointer AcquireFirstMatchingEventInQueue(Pointer inQueue,NativeLong inNumTypes,EventTypeSpec[] inList, NativeLong inOptions);
//... so on
}
問題を解決するには、以下の機能を使用して解決される。
NativeLong ReceiveNextEvent(NativeLong inNumTypes, EventTypeSpec[] inList, double inTimeout, byte inPullEvent, Pointer outEvent);
これは仕事をしていません。ドキュメントごとに - また
This routine tries to fetch the next event of a specified type.
If no events in the event queue match, this routine will run the
current event loop until an event that matches arrives, or the
timeout expires. Except for timers firing, your application is
blocked waiting for events to arrive when inside this function.
ないReceiveNextEvent
場合、MCarbon
クラスで述べたように、他の機能は、上記有用であろう。
私はCarbon
フレームワークdocumentationは、問題を解決するためのより多くの洞察と柔軟性を与えると思います。 Carbon
のほかに、フォーラムで人々はCocoa
を使って解決について言及しましたが、私は気付いていません。
編集:technomargeのおかげで、より多くの情報あなたはおそらくチェックアウトしたくなるでしょうhere
GCEventRef、https://developer.apple.com/library/mac/documentation/Carbon/Reference/QuartzEventServicesRef/Reference/reference .html –
UNIX用のJNAのプラットフォームマッピングのほとんどはX11向けであり、OS Xにはあまり特筆すべきものはありません。[Rococoa](http://code.google.com/p/rococoa/) OS Xマッピングの – technomage
@technomageロココアに移行することはできません。コードを書き直さなければならないからです。 Windowsは既にうまく動作します。メッセージを受け取るための技術が必要です。 – Jatin