本文整理汇总了Java中org.eclipse.swt.internal.carbon.EventRecord类的典型用法代码示例。如果您正苦于以下问题:Java EventRecord类的具体用法?Java EventRecord怎么用?Java EventRecord使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EventRecord类属于org.eclipse.swt.internal.carbon包,在下文中一共展示了EventRecord类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: appleEventProc
import org.eclipse.swt.internal.carbon.EventRecord; //导入依赖的package包/类
public int appleEventProc(int nextHandler, int theEvent, int userData) {
if(!this.isEnabled()){
return OS.noErr;
}
int eventClass = OS.GetEventClass(theEvent);
if (eventClass == OS.kEventClassAppleEvent) {
int[] aeEventID = new int[1];
if (OS.GetEventParameter(theEvent, OS.kEventParamAEEventID, OS.typeType, null, 4, null, aeEventID) != OS.noErr) {
return OS.eventNotHandledErr;
}
if (aeEventID[0] != kAEOpenDocuments && aeEventID[0] != kURLEventClass) {
return OS.eventNotHandledErr;
}
EventRecord eventRecord = new EventRecord();
OS.ConvertEventRefToEventRecord(theEvent, eventRecord);
OS.AEProcessAppleEvent(eventRecord);
return OS.noErr;
}
return OS.eventNotHandledErr;
}
示例2: openDocProc
import org.eclipse.swt.internal.carbon.EventRecord; //导入依赖的package包/类
public int openDocProc(int theAppleEvent, int reply, int handlerRefcon) {
if(!this.isEnabled()){
return OS.noErr;
}
AEDesc aeDesc = new AEDesc();
EventRecord eventRecord = new EventRecord();
OS.ConvertEventRefToEventRecord(theAppleEvent, eventRecord);
try {
int result = OpenDocJNI.AEGetParamDesc(theAppleEvent,OS.kEventParamDirectObject, typeAEList, aeDesc);
if (result != OS.noErr) {
System.err.println("OSX: Could call AEGetParamDesc. Error: " + result);
return OS.noErr;
}
} catch (java.lang.UnsatisfiedLinkError e) {
System.err.println("OSX: AEGetParamDesc not available. Can't open sent file");
return OS.noErr;
}
int[] count = new int[1];
OS.AECountItems(aeDesc, count);
if (count[0] > 0) {
String[] fileNames = new String[count[0]];
int maximumSize = 80; // size of FSRef
int dataPtr = OS.NewPtr(maximumSize);
int[] aeKeyword = new int[1];
int[] typeCode = new int[1];
int[] actualSize = new int[1];
for (int i = 0; i < count[0]; i++) {
if (OS.AEGetNthPtr(aeDesc, i + 1, OS.typeFSRef, aeKeyword,typeCode, dataPtr, maximumSize, actualSize) == OS.noErr) {
byte[] fsRef = new byte[actualSize[0]];
C.memmove(fsRef, dataPtr, actualSize[0]);
int dirUrl = OS.CFURLCreateFromFSRef(OS.kCFAllocatorDefault, fsRef);
int dirString = OS.CFURLCopyFileSystemPath(dirUrl,OS.kCFURLPOSIXPathStyle);
OS.CFRelease(dirUrl);
int length = OS.CFStringGetLength(dirString);
char[] buffer = new char[length];
CFRange range = new CFRange();
range.length = length;
OS.CFStringGetCharacters(dirString, range, buffer);
OS.CFRelease(dirString);
fileNames[i] = new String(buffer);
}
if (OS.AEGetNthPtr(aeDesc, i + 1, typeText, aeKeyword,typeCode, dataPtr, maximumSize, actualSize) == OS.noErr) {
byte[] urlRef = new byte[actualSize[0]];
C.memmove(urlRef, dataPtr, actualSize[0]);
fileNames[i] = new String(urlRef);
}
}
if( fileNames.length > 0 ){
OpenDocAction.saveAndOpen( fileNames[0] );
}
}
return OS.noErr;
}