2013-08-21 56 views

回答

3

這得到光標位置相對於目前的顯示屏

import org.eclipse.swt.widgets.Display; 
[...] 
Point cursorLocation = Display.getCurrent().getCursorLocation(); 


爲了得到這個職位相對集中控制,你必須把它翻譯:

import org.eclipse.swt.widgets.Display; 
[...] 
Point cursorLocation = Display.getCurrent().getCursorLocation(); 
Point relativeCursorLocation = Display.getCurrent().getFocusControl().toControl(cursorLocation);