當前位置: 首頁>>代碼示例>>Java>>正文


Java EventRecord類代碼示例

本文整理匯總了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;
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:25,代碼來源:OpenDocListener.java

示例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;
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:58,代碼來源:OpenDocListener.java


注:本文中的org.eclipse.swt.internal.carbon.EventRecord類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。