Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-ui-dev] TextEditorActions and selection/position-dependent actions?

Robert,

The behavior you are seeing is inherited from the SWT StyledText widget. When adding a SelectionListener to a StyledText instance you experience the same behavior. The addition provided by the TextViewer is the adaptation to the selection protocol of the class Viewer and the fact that selection change events are also sent out on programmatic changes of the selection. The AbstractTextEditor implements an approximation to a "cursor position listener" by registering itself as KeyListener and MouseListener on the StyledText widget.

Kai

At 05:06 PM 4/21/2003 -0400, you wrote:
I've got a TextEditorAction that I want to be both selection-
and position-activated, i.e. so that it's enabled at some
textual positions but not others.

So, I've marked it as selection-dependent; i.e., I called
AbstractTextEditor.markAsSelectionDependentAction(myAction).

I've found that changing the cursor position doesn't always
result in calling an action's IUpdate.update(), so my action
doesn't always get the chance to enable/disable itself.

Specifically, if the selection is empty, cursor motion via the
arrow keys or mouse pointer does NOT call update().

If the selection is NON-empty, cursor motion via the arrow keys
or mouse DOES call update() (presumably since the selection goes
from non-empty to empty).

One could argue that this is all a red herring since I can work
around the problem by not attempting to enable/disable my action,
but rather make it a no-op if the position is not one it should
handle.

On the other hand, I think that an empty selection is still a
selection (zero length but at a specific document offset), so
moving the cursor from one spot to another changes the selection,
but clearly AbstractTextEditor disagrees with me. :-)

Thoughts?


--------------------------------
Dr. Robert M. Fuhrer                         rfuhrer@xxxxxxxxxxxxxx
Programming Technologies           IBM T. J. Watson Research Center

_______________________________________________
platform-ui-dev mailing list
platform-ui-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-ui-dev


Back to the top