Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Mouse selections in StyledText and TextViewer


Already replied to Alan...

----- Forwarded by Lynne Kues/RAL/OTI on 09/13/2002 05:05 PM -----
Lynne Kues

09/13/2002 03:25 PM


        To:        alan@xxxxxxxxxxxx
        cc:        knut_radloff@xxxxxxx
        Subject:        Re: [platform-swt-dev] Mouse selections in StyledText and TextViewerLink





"Alan Oursland" <alan@xxxxxxxxxxxx>
Sent by: platform-swt-dev-admin@xxxxxxxxxxx

09/12/2002 04:06 PM
Please respond to platform-swt-dev

       
        To:        <platform-swt-dev@xxxxxxxxxxx>
        cc:        
        Subject:        [platform-swt-dev] Mouse selections in StyledText and TextViewer


I have been looking at the code for selecting text with the mouse in the
text editor. It looks like StyledText implements most of it and then
TextViewer implements it again.

I have also noticed that selection actions are pretty much hardcoded to the
mouse events.

I would like to rewrite the mouse selection code so that:
a) it works like the editor in MS Visual Studio by default
b) it is customizable

My main reservation with this endeavor is that I have zero understanding of
how changes will affect plug-ins that other people have written. Could
someone provide any information on this and how I can avoid impact.


Have you looked at the Platform Plug-in Developer and the JDT Plug-in Development Guides?  These guides discuss how to plug-in to the workbench in order to extend the existing behavior.  There is also an example of creating a customized Java Editor.

The JavaSourceViewerConfiguration is intended to be used for customizing the JavaEditor, but it doesn't look like it gives you what you need.  This is really a JDT issue (vs. an SWT issue).  The question being "How do I extend the Java Editor selection behavior?"  The JavaSourceViewerConfiguration class references a text editor and if you could access this variable you could hook the mouse events and provide special processing (see discussion below), but there is not API for doing this, nor is the class intended to be subclassed.

The changed I would like to make are:
I. get rid of IDoubleClickStrategy and all support (affects ITextViewer,
TextViewer, and SourceViewerConfiguration)


Why not just introduce a DoubleClickStrategy that does nothing/what you want?  As I understand it, this is the intended use of SourceViewerConfiguration (i.e., you can customize the given behavior).

II. introduce a new more general model for customizing mouse selection in
StyledText where:
                a) A mouse down event (including multi-clicks):
                                 - clears the current selection unless shift is pressed (shift always
extends selections)
                                 - records a selection start position.
                                 - uses modifiers (ctrl, alt, click-count) to find a content partitioning
object.
                                 - sets the selection to the left and right bounds of the partition in
which the mouse was pressed.
                                 - begins autoscrolling
                b) A mouse move event
                                 - makes sure a mouse drag selection is taking place
                                 - gets the correct content partitioning based on modifiers
                                 - extends the selection to the left and right bounds of the partitions
that the start position and current mouse position span.
                c) A mouse up event
                                 - ends autoscrolling


I think you could do this by hooking the MouseEvents on the StyledText widget for the editors in which you want this behavior.  Have you tried this at all (hooking the events on a StyledText widget and supplying the additional selection behavior)?  The content partitioning is supported via JFace Text.  See below.  You shouldn't change StyledText, but either extend the existing editors or introduce your own editor.

Content Partitioning objects define partitions within content. I am pretty
sure I remember seeing something like this in Eclipse already, but it
doesn't seem to be associated with StyledTextContent. You might have
different partitioning objects for words, lines, programming scopes, or
whatever. Each editor would be able to map mouse modifiers to their own
custom partitioning object. A default, or null, partitioning object would
indicate single character partitioning.


The org.eclipse.jface.text.* packages have this support.

Note that there is no functional difference between MouseClick and
MouseDoubleClick events. Ideally, this should also be able to handle triple
clicks, if the event model were to support it.

What this does not support is block selection. To do that, I think that
selection state would need to be encapsulated inside an object, or multiple
selections would need to be supported in the widget (which doesn't make a
lot of sense to me).

I would appreciate any comments on this.

Alan Oursland


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




Back to the top