Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-text-dev] Going from ITextEditor toITextViewerandback

If you only read values it's not an issue, but if you change things on StyledText it *might* interfere with features implemented in the viewer or the editor.

Dani



From:        Nathan Ridge <zeratul976@xxxxxxxxxxx>
To:        Eclipse Platform Text component developers list <platform-text-dev@xxxxxxxxxxx>
Date:        08.08.2018 19:20
Subject:        Re: [platform-text-dev] Going from ITextEditor to        ITextViewer        andback
Sent by:        platform-text-dev-bounces@xxxxxxxxxxx




> It is not a good practice to access the text widget unless you do it for your own editor. Please see org.eclipse.jface.text.ITextViewer.getTextWidget() for details.

Let me give a concrete example.

In this StackOverflow question [1], a user is writing a plugin that provides a context menu action, and they want to write a filter for the action that enables the action based on what in the editor was right-clicked.

To do this, they need to map the coordinates of the right-click in the editor, to a character offset. StyledText provides a public API for doing this, getOffsetAtPoint(), so I suggested that they use getAdapter() to obtain the StyledText, and then getOffsetAtPoint() to obtain the character offset.

Is there something wrong with this? Is there a better way that I could have suggested?

Thanks,
Nate

[1]
https://stackoverflow.com/questions/51710935/eclipse-cdt-plugin-get-ast-element-based-of-x-and-y-position-of-mouse-click-in/
_______________________________________________
platform-text-dev mailing list
platform-text-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/platform-text-dev





Back to the top