Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » TextEditors SelectionListener inconsist???
TextEditors SelectionListener inconsist??? [message #175915] Mon, 05 January 2004 16:52 Go to next message
Eclipse UserFriend
Hi ...

while playing with the TextEditors SelectionListener i observed the
folowing behavior:
- when the selection is changed an event is generated .. great
- when the selection goes empty an event with an empty selection is
generated that contains the cursor position .. terrific
- when special editor actions are performed such as goto start of line
or next word or end of line an selection event with an empty selection
and the current cursorposition is fired .. wonderful ..
- when normal cursor movements with the mouse or the arrow keys are
performed no event is triggered .. too sad ... i really would like
these events similar to the special movements ...

i want to create an plugin that needs the current cursor position
whenever it changes ... perhaps an listener to the NavigationHistory
would be a solution too, but i cant find an api to register as listener.

thanks in advance

christian koestlin
Re: TextEditors SelectionListener inconsist??? [message #176163 is a reply to message #175915] Tue, 06 January 2004 04:10 Go to previous messageGo to next message
Eclipse UserFriend
The normal selection listener gets only notified when the length /
position of a non-empty selection changes, i.e. not on scrolling through
an editor. Your third point seems to show an inconsistency with this.

See PostSelectionProvider for getting informed about caret changes (but
note you only get notified after a delay).

-t

Christian Köstlin wrote:
> Hi ...
>
> while playing with the TextEditors SelectionListener i observed the
> folowing behavior:
> - when the selection is changed an event is generated .. great
> - when the selection goes empty an event with an empty selection is
> generated that contains the cursor position .. terrific
> - when special editor actions are performed such as goto start of line
> or next word or end of line an selection event with an empty selection
> and the current cursorposition is fired .. wonderful ..
> - when normal cursor movements with the mouse or the arrow keys are
> performed no event is triggered .. too sad ... i really would like
> these events similar to the special movements ...
>
> i want to create an plugin that needs the current cursor position
> whenever it changes ... perhaps an listener to the NavigationHistory
> would be a solution too, but i cant find an api to register as listener.
>
> thanks in advance
>
> christian koestlin
Re: TextEditors SelectionListener inconsist??? [message #176330 is a reply to message #176163] Tue, 06 January 2004 15:27 Go to previous message
Eclipse UserFriend
Tom Eicher wrote:

> The normal selection listener gets only notified when the length /
> position of a non-empty selection changes, i.e. not on scrolling through
> an editor. Your third point seems to show an inconsistency with this.
mhh ... not really ...
if there is a selection and this changes (is deselected) an event is
fired ... with the event trigger definition of yours this seems
reasonable

> See PostSelectionProvider for getting informed about caret changes (but
> note you only get notified after a delay).
great ... this works ... wonderful!
i didnt see this because of the needed downcast ... mhhh ... i
discovered another inconsistency???
the events that are fired by the post-provider deliver textselections,
with length 0 but isEmpty returns false ... so the only test that works
is for textSelection.getLength() > 0 ... which is consistent with the
apidocs: "...Returns true if the offset and length are smaller than
0..." but its another behavior than the events the normal selection
listener gets ...

thanks for your help!

cK
Previous Topic:Setting a listener on the Package Explorer?
Next Topic:Problems with CVS Watch/Edit under Eclipse in combination with cygwin
Goto Forum:
  


Current Time: Wed Jul 16 16:36:30 EDT 2025

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

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

Back to the top