Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » get caret always returns null ?
get caret always returns null ? [message #160192] Fri, 21 November 2003 11:52 Go to next message
Eclipse UserFriend
Hi !
I built a plugin that is a menu item in the java editor's popup menu.
I need to get the caret position from the editor. I tried different
"paths" to get to the caret, something like :

IEditorPart lastEditor;
// ...
lastEditor.getEditorSite().getPage().getWorkbenchWindow().ge tShell().getCaret();

But getCaret() always return null... ? Anybody knows why or how I can get
the caret's position ?

Thank all !

M.
Re: got it, no need to reply thanks [message #160207 is a reply to message #160192] Fri, 21 November 2003 12:08 Go to previous message
Eclipse UserFriend
OK, I got it... Actually, I only needed current line... Here is how I got
it (in case someone needs it) :


ISelection sel = ((ITextEditor)
(lastEditor).getSelectionProvider().getSelection();
System.out.println(((ITextSelection)sel).getStartLine());

--> where "lastEditor" is an IEditorPart implementer.
M.
Previous Topic:How to debug a Tomcat servlet?
Next Topic:Installing user local plugins
Goto Forum:
  


Current Time: Sat May 10 00:56:03 EDT 2025

Powered by FUDForum. Page generated in 1.05331 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top