Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6861779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:34:45+00:00 2026-05-27T02:34:45+00:00

Disclaimer When I wrote this question I was wrong about the behavior of the

  • 0

Disclaimer

When I wrote this question I was wrong about the behavior of the SelectionService…the SelectionService does normally notify about cursor movement, but not for every movement either: having your IDE rapidly flash through showing detailed information as you scroll your cursor up 10 lines to get to what you’re interested in is both useless, as the information is displayed for much too short a period to be useful, highly distracting, and perhaps even dangerous to those with potential epilepsy.

For this reason, the SelectionService responds only after the cursor has been left in the same place long enough that it makes sense for Eclipse views to update in response to the new context.

I’ve also heard that there was one Eclipse version some years back in which the SelectionService was bugged, so I’m not sure whether I posted this because I happend to first develop Eclipse plugins in exactly that version, or because I didn’t understand why the SelectionService works the way it does, but in the end, using the Eclispe SelectionService is all I’ve ever needed, or would recommend to others.

The original question

I’m developing an Eclipse plugin that needs to respond to the current cursor position in an Eclipse editor.

From the tests I’ve done, it appears that using the SelectionService only tells you when a non-empty selection is made in an editor, not when the cursor is moved.

I’ve found one site describing how to track selections by registering for mouse and keyboard events, but that seems like a bit of a hack.

I’ve also seen someone asking on StackOverflow about alternatives to the CaretListener interface for tracking cursor movement in an Eclipse editor, and describing a way to register with an editor’s text viewer (rather than the global SelectionService) to get caret movement updates, but they suggest that it’s a less-effecient method that would be better replaced with the CaretListener interface in more recent versions of Eclipse.

That last might be an option, but it sounds like using the CaretListener would be the preferred approach…but if it is, how can it be done?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:34:46+00:00Added an answer on May 27, 2026 at 2:34 am

    If you can live without supporting older Eclipse versions (3.4 and below) then CaretListener is definitely the way to go. Older StyledText implementations don’t send any notifications about caret movement.

    Get access to the StyledText control of the editor as described in your first link, but instead of adding key or mouse listeners, add a CaretListener.

    workbenchWindow.getActivePage().addPartListener(new PartListener() {
        public void partOpened(IWorkbenchPartReference partRef) {
            //Check if this is an editor and its input is what I need
            AbstractTextEditor e =
                (AbstractTextEditor)((IEditorReference) partRef).getEditor(false);
            ((StyledText)e.getAdapter(Control.class)).addCaretListener(l);
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Disclaimer: This is not actually a programming question, but I feel the audience on
Disclaimer: This is for a homework assignment, but the question is not regarding the
Disclaimer This is not strictly a programming question, but most programmers soon or later
Full disclaimer: this is not really a homework, but I tagged it as such
Disclaimer : this is not a how to question. I would more like to
Disclaimer: I understand the question is very basic, but I could not find the
Disclaimer: I am a n00b. It seems like ODBC does not support a BOOLEAN
Disclaimer: please do not bother reading this long post unless you are an embedded
Disclaimer: I am anything but a Javascript expert, so I'm not even sure if
Disclaimer: this question is directly related to my programming homework. My C++ assignment consists

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.