Bug 14654 - [typing] Single line selection on triple-click
Summary: [typing] Single line selection on triple-click
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.1   Edit
Hardware: All All
: P2 enhancement with 27 votes (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Felipe Heidrich CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 21310 28733 51725 107974 143724 (view as bug list)
Depends on: 23614 177927
Blocks:
  Show dependency tree
 
Reported: 2002-04-25 13:35 EDT by Vladimir Grishchenko CLA
Modified: 2007-04-09 11:23 EDT (History)
28 users (show)

See Also:


Attachments
patch for double click, hold and drag and triple click (8.65 KB, application/x-zip-compressed)
2004-09-03 04:05 EDT, Marc Guenther CLA
no flags Details
zip file for double/triple click patch (8.65 KB, application/zip)
2004-09-03 04:16 EDT, Marc Guenther CLA
no flags Details
patch to add support for triple-clicking (19.85 KB, patch)
2005-06-07 19:22 EDT, Chris Wiebe CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Grishchenko CLA 2002-04-25 13:35:40 EDT
This is a common and convenient behavior for text editors/IDEs which is 
missing. Would be nice to have it. Switching to keyboard and doing "shift+arrow 
down" seems like a lot more effort for achieving the same effect.
Comment 1 Mike Wilson CLA 2002-04-25 14:11:19 EDT
Some people like this functionality, and some don't. In addition, whether or 
not this makes sense is at least partially related to the domain of the editor 
(for example, "select-a-line" makes sense for a Java editor, but "select-a-
sentance" or "select-a-paragraph" might be more appropriate for a plain text 
editor).

There are two possible places where it could show up. One is in the native 
widgets, in which case, if it happens at all it will be as a side-effect of 
the normal functioning of the native widget.

The other possibility is in the StyledText code. StyledText is a custom widget 
whose behavior is defined by the needs of the Eclipse UI team. It *is* 
platform neutral, so if triple-click were to be added, it would show up on all 
platforms.

Note that, few (none?) of the operating systems SWT is implemented on provide 
triple-click notification, so this would have to be done by detecting the 
event times in the StyledText code.

Moving to the UI team for consideration.
Comment 2 Nick Edgar CLA 2002-04-25 14:26:55 EDT
Defer for consideration after 2.0.
Semantics based selection expansion may be preferable even in code (see Edit / 
Expand Selection).
Comment 3 Randy Giffen CLA 2002-08-12 09:29:02 EDT
Reopen to move
Comment 4 Randy Giffen CLA 2002-08-12 09:29:19 EDT
Move to text
Comment 5 Kai-Uwe Maetzel CLA 2002-09-12 11:28:07 EDT
*** Bug 21310 has been marked as a duplicate of this bug. ***
Comment 6 Alex Chaffee CLA 2002-11-10 13:49:09 EST
> Some people like this functionality, and some don't.

Then make it optional, but *please* make it.  Triple-click has been an 
important part of code editors (starting on the Mac, but soon spreading 
everywhere) for over ten years.

Make sure you also implement triple-click-and-drag (which selects and deselects 
entire lines as the cursor is dragged over them).

By the way, double-click-and-drag is also unimplemented, which is unfortunate.

See http://developer.apple.com/techpubs/mac/HIGuidelines/HIGuidelines-205.html 
for the thoughts of people who have thought about this a lot (they agree that 
in different contexts, triple-click may mean "select sentence" or "select 
paragraph").

Comment 7 Bob Foster CLA 2002-11-10 18:51:55 EST
1. Paragraph selection only makes sense for editors that wrap. Otherwise, there
are only lines.

2. If you do happen to implement selection drag and drop, please make it
optional. It's an invention of the devil.
Comment 8 Alex Chaffee CLA 2002-11-11 12:15:00 EST
> If you do happen to implement selection drag and drop, please make it
optional. It's an invention of the devil.

Absolutely!  Let me be clear: double-click-and-drag is when you click down-up-
down, then immediately start to drag the cursor.  It expands the selection 
area, selecting entire words (*not* merely individual characters) as those 
words come under the cursor.  It's akin to shift-control-rightarrow in Word and 
other editors.

Triple-click-and-drag expands and shrinks the selection line by line.

Selection drag and drop is stupid and whoever invented it should be dragged 
over broken glass and dropped in a spiked pit.

Comment 9 Zach Pincus CLA 2003-01-23 05:14:33 EST
This bug is closely related to bug 22880, which details how to implement this 
click-hold and multiple-click behavior.

A specific complaint about how double-click and drag (often referred to as 1.5 
click: mouse-down, mouse-up, mouse-down, and hold while you drag is not quite 2 
full clicks!) should work can be found in bug 21336.

Regarding these questions, it should be noted that on almost all editors, on 
almost all platforms, double-clicking selects a word and double-clicking and 
then dragging (1.5 clicks and a drag) extends the selection word-wise. Triple-
click behavior is less uniform.

While it may be annoying to some that triple-clicking doesn't select a line 
(and I agree that it should!), the behavior on 1.5-click and drag is truly 
asinine:
If you 1.5-click on a word and then move the mouse, the selection extends by 
characters, not by words. Then, on mouseup, the selection reverts back to only 
include the originally clicked-on word. This is doubly unexpected and bad 
behavior, and should be fixed in the same set of fixes that defines triple-
click behavior.
Comment 10 Alex Chaffee CLA 2003-03-06 09:59:13 EST
For the double-click-and-drag issue, see (and vote for!) bug 33193

Comment 11 Dani Megert CLA 2004-02-11 16:39:34 EST
*** Bug 51725 has been marked as a duplicate of this bug. ***
Comment 12 Marc Guenther CLA 2004-09-03 04:05:59 EDT
Created attachment 14386 [details]
patch for double click, hold and drag and triple click

I have attached a small patch which allows you to:
- double click, hold and drag to select multiple words
- triple click to select lines

the triple click stuff works only on MacOSX (carbon). The double click might
work on other OS' too, but I don't have access to other boxes.

The patch is against version R3_0.

Basically I made these changes:

1. for triple click:

org.eclipse.swt: 
  I introduced a 'int click_count' member to Event.java and MouseEvent.java.
  This is set from inside of sendMouseEvent() in Control.java and works
  with any number of mouse clicks

org.eclipse.jface.text:
  Added a new class ITextTripleClickStrategy, which adds one method
  tripleClicked()
  In TextViewer$TextDoubleClickStrategyConnector I added
  fClickCount and mouseDown(). fClickCount remebers the click count
  of the last mouseDown
  In mouseUp() if the fClickCount is 3, I send a tripleClicked() if the
  Strategy is a ITextTripleClickStrategy
  DefaultTextDoubleClickStrategy implements ITextTripleClickStrategy
  and adds tripleClicked() method

org.eclipse.jdt.ui:
  JavaDoubleClickSelector also implements ITextTripleClickStrategy
  and adds tripleClicked() method

2. for double click n drag support (this should work on all platforms)

org.eclipse.jface.text.DefaultTextDoubleClickStrategy
  and
org.eclipse.jdt.ui.JavaDoubleClickSelector
  
  Changed the doubleClicked() method to use the start AND end point
  of the mouse selection to calculate the resulting selection.

  JavaStringDoubleClickSelector calls super instead of selectWord()
  directly

Comments:
- The feedback during the mouse drag is still wrong.
- Shift-Clicking doesn't remember that the original click was a
  double/triple click (always selects characters)
- To make this work on Win* and other OS', basically what I do here in
  SWT/carbon: org.eclipse.swt.widgets.Control.sendMouseEvent()
  (getting the click count and store it into the Event) has to be duplicated.
  Everything else should work from there.
Comment 13 Marc Guenther CLA 2004-09-03 04:16:19 EDT
Created attachment 14387 [details]
zip file for double/triple click patch

trying to submit again, last attachment was displayed as text...
Comment 14 Dani Megert CLA 2004-09-03 04:19:04 EDT
Thanks for the patch. We will look at this when we attack the corresponding 3.1
plan item:

- interaction (mouse, keyboard)
    * selection modes (line selection, word selection)
Comment 15 Peter Eastman CLA 2004-12-04 14:53:02 EST
Handling of double/triple clicks is something that a lot of editors get wrong in a variety of subtle ways.  
Here are the details of what I consider to be the "correct" behavior.

1. Double-click should select the clicked work on the second mouse press (*not* release).  It should 
*not* select spaces or punctuation marks to either side of the word.  Double-clicking on a space or 
punctuation mark should select only that character.

2. Double-click-drag should select a sequence of whole words.

3. Triple-click should select the clicked line, *including* the carriage return at the end of it.  (Swing 
messes up on that one.)  Again, selection should occur on mouse down, not mouse up.  It should not 
matter where in the line you click.  In particular, triple-clicking to the right of the last character should 
still select the line.  (IDEA 3.x messed up on that one, but they fixed it in 4.0.)

4. Triple-click-drag should select a series of whole lines, again including the carriage return at the end 
of the last line.  (jEdit, which otherwise gets everything right, messes up on that last carriage return.)
Comment 16 Felipe Heidrich CLA 2005-02-25 15:37:03 EST
*** Bug 82398 has been marked as a duplicate of this bug. ***
Comment 17 Dani Megert CLA 2005-03-29 16:34:50 EST
*** Bug 28733 has been marked as a duplicate of this bug. ***
Comment 18 Chris Wiebe CLA 2005-06-07 19:22:33 EDT
Created attachment 22577 [details]
patch to add support for triple-clicking

This patch adds support for triple-clicking (or as many clicks as you like) to
select an entire line.	I have taken a simliar approach to Marc Guenther's
patch, only this one doesn't require any swt changes and is limited to just one
plugin - org.eclipse.jface.text.

This patch also changes the double- and triple-click to select on the mouse
down event, rather than the mouse up event.  This behaviour is consistent with
the way most text editors work (I tried several editors on both Mac OS and
Windows and they all selected on mouse-down).  If people prefer the current
Eclipse way, perhaps this could be made into a preference option.
Comment 19 Chris Wiebe CLA 2005-06-24 17:52:23 EDT
Who do we have to bribe to get this feature implemented? ;) Looks like this bug has been open for over 3 
years now.  Is there any chance of getting something like an extension point in place for 3.1?  Please throw 
us poor folks a bone!
Comment 20 Markus Keller CLA 2005-06-27 06:55:14 EDT
Chris, I'm sure the Text team will look at your patch after 3.1 is out. I guess
it came a bit too late for inclusion in 3.1 since we were already in a
stabilization lockdown phase by that time.

I've tried your patch, and I discovered that it does not implement several items
of Peter's comment 15 "correctly" (IMO, that list shows the desired behavior,
except for double-clicking a tab or a space, which should select all adjacent
whitespace except for line delimiters).

1. Double-clicking on a tab before a word as in
		System.out.println();
selects the tab and the next word. Should only select the tab(s) before the word.

2. Double-click-and-hold does not expand the selection word-wise, but
character-wise.

3. Triple-click should select the clicked line, *including* the line
delimiter(s) at the end of it. The patch misses the line delimiter.

4. See 2. and 3.
Comment 21 Marc Guenther CLA 2005-06-27 07:26:31 EDT
Hi Markus,
> Chris, I'm sure the Text team will look at your patch after 3.1 is out.
Sorry to say, but the same I heard last year about my patch, it will be worked on after 3.0 comes out. 
But unfortunately that never happened. So who do we need to bribe again? :-)

btw, I agree with the desired behauvoir you describe, espacially about double clicking on white space. 
Chris, are you interested in implementing the changes Markus described? Otherwise I might give it a 
try.
Comment 22 Chris Wiebe CLA 2005-06-27 13:36:22 EDT
I agree that Peter's way (comment 15) is the "right way."  It should be the default behaviour for a generic 
text editor, with the ability to override/customize behaviour for different kinds of editors.  My patch was a 
bit too simplistic.

Marc, feel free to tackle this... :)
Comment 23 Dani Megert CLA 2005-06-28 04:42:38 EDT
>> Chris, I'm sure the Text team will look at your patch after 3.1 is out.
>Sorry to say, but the same I heard last year about my patch, it will be worked
>on after 3.0 comes out. 
>But unfortunately that never happened. So who do we need to bribe again? :-)

Please read comment 14 again ;-) The mentioned item wasn't on the committed
items list and there was unfortunately not enough time to attack it, that's why
we did not look at these patches yet.

There were already several comments in that PR what should/will happen upon
double- and tripple-click: this is up to each viewer / editor e.g. Java defines
its own double-click strategy and hence changes/whishes regarding the
functioning of double- and tripple-click in individual editors should be placed
there.

Chris, one thing that I didn't like in your patch is the 'multi'. I suggest to
keep it to "Tripple" otherwise we should also add support registering of more
than one multi click strategy.
Comment 24 Dani Megert CLA 2005-06-28 04:49:04 EDT
Note that we are still waiting for an answer whether StyleText will provide
tripple-click mouse events (see bug 23614). I've just pinged them again in the bug.
Comment 25 Chris Wiebe CLA 2005-06-28 14:23:58 EDT
> Chris, one thing that I didn't like in your patch is the 'multi'. I suggest to
> keep it to "Tripple" otherwise we should also add support registering of more
> than one multi click strategy.

Actually this was deliberate.  It's very annoying to have to do precisely 3 clicks to select a line.  What most 
editors do is treat 3 or more clicks the same as a triple-click, but they definitely don't limit you to exactly 
3 clicks.  You're probably right though in that no one's going to want to register more than one multi-click 
strategy (ie if 3  clicks do this, if 4 clicks do this, etc).  Calling it "Triple" rather "Multi" is fine as long as it 
still works with >3 clicks.
Comment 26 Dani Megert CLA 2005-08-25 08:03:38 EDT
*** Bug 107974 has been marked as a duplicate of this bug. ***
Comment 27 Sean Montgomery CLA 2006-01-12 10:36:27 EST
Just FYI, as a pseudo-workaround until this feature gets implemented - if you're in a Java editor and have the line number display turned on, clicking on the line number selects the line.

Unfortunately it doesn't appear to get the newline, though, grrr.  At least not in Eclipse 3.2M4.  But that's another bug.
Comment 28 Marc Guenther CLA 2006-02-13 14:49:55 EST
see bug 5138, comment 16 for a patch for triple click on MacOSX and double click and drag
Comment 29 Dani Megert CLA 2006-02-14 05:00:26 EST
Marc, I suggest to add the SWT portion of the tripple-click patch/comments to bug 23614.
Comment 30 Dani Megert CLA 2006-05-25 16:24:41 EDT
*** Bug 143724 has been marked as a duplicate of this bug. ***
Comment 31 Sean Montgomery CLA 2006-06-16 09:48:46 EDT
Now that the 3.3 design phase is here, I'm sure I speak for all the voters for this bug and tons of other Eclipse users with a Mac background when I say this really needs to be addressed.

There are 27 votes for this bug, but far fewer votes for 23614 which is blocking it.  Vote for the blocker, too!

And all you lurkers out there: vote.  You know you want your triple-click.
Comment 32 Kendall Lister CLA 2006-08-05 22:35:39 EDT
I'm trying to be helpful, so I apologise if this is a mistake. The bug that was blocking this one is marked FIXED now, so if someone was waiting for that to happen before fixing this one, go go go! :)
Comment 33 Marc Guenther CLA 2006-08-16 05:36:24 EDT
My old patch ported to 3.2 is available here:
http://www.biffy-berlin.de/marc/doubleTripleClick_patch_320.zip

binaries are here:
http://www.biffy-berlin.de/marc/doubleTripleClick_jars_320.zip

Marc
Comment 34 Marc Guenther CLA 2007-02-27 03:45:21 EST
And here's my old patch ported to 3.2.2:
http://www.biffy-berlin.de/marc/doubleTripleClick_patch_322.zip
Comment 35 Mike Wilson CLA 2007-03-16 13:16:33 EDT
In case this is being held up by my negative comments in comment #1, I don't have a problem with this going into 3.3. If there are API changes, it still needs a request on the pmc mailing list.
Comment 36 Dani Megert CLA 2007-03-16 13:18:25 EDT
It's there since a few minutes :-)
Comment 37 Mike Wilson CLA 2007-03-16 13:27:00 EDT
Ah, Dani, you know how slow I am. ;-)

+1 to the API changes.
Comment 38 Dani Megert CLA 2007-03-18 07:56:07 EDT
Fixed in HEAD.
Available in builds > N20070318-0010.

Per default triple-click will select the line using the new LineSelectionTextTripleClickStrategy. Clients can override this via SourceViewerConfiguration.getTripleClickStrategy(...).

NOTE: currently triple-click only works if text drag and drop is disabled, see bug 177927 for details.
Comment 39 Markus Keller CLA 2007-03-20 06:05:10 EDT
Verified in I20070320-0010.

I've added bug 178208 and bug 178209 for subtleties from comment 15, and bug 178210 for comment 20.
Comment 40 Dani Megert CLA 2007-03-21 17:07:00 EDT
Making single-line selection on triple-click worked just fine but it turns out that triple-click + mouse move to select multiple lines is hard to do smooth from outside StyledText, see discussions in bug 138579. After discussion with SWT we agreed to pull out the flexibility to configure triple-click from outside but instead directly provide single line selection on triple-click and multi line selection on triple-click + mouse move through the StyledText widget.

This means the following new APIs got removed again for M6:
  ITextTripleClickStrategy
  ITextViewerExtension7.setTextTripleClickStrategy(...)
  LineSelectionTextTripleClickStrategy
  SourceViewerConfiguration.getTripleClickStrategy(...)

For M6 I left internal code in place so that at least single line selection on triple-click works.

Comment 41 Dani Megert CLA 2007-03-21 17:08:18 EDT
Moving to SWT to provide this feature for 3.3.
Comment 42 Felipe Heidrich CLA 2007-03-22 17:44:07 EDT
Dani, in StyledText - in our initial design - if you disable double click (StytedText#setDoubleClickEnable(false)) it will disable triple-click too.
Is that okay ? 
Comment 43 Dani Megert CLA 2007-03-23 05:59:18 EDT
>Dani, in StyledText - in our initial design - if you disable double click
>(StytedText#setDoubleClickEnable(false)) it will disable triple-click too.
>Is that okay ? 
Yes, this is fine. In order to make sure other clients learn about this it might be a good idea to deprecate that method and add a new one, e.g.
setSelectionOn[Mouse]Click(boolean).
Comment 44 Felipe Heidrich CLA 2007-03-26 17:13:32 EDT
fixed in HEAD > 20070326

Dani, StytedText#setDoubleClickEnable(false) - also disables triple click.

In the future we can decide to deprecate this API and add new ones with better names (right now due the API freeze I can not change anything).
Comment 45 Dani Megert CLA 2007-03-27 04:30:56 EDT
Thanks. For the next I-build I removed the temporary triple-click code that I added for M6 and fixed bug 5138 which means text viewers now use StytedText#setDoubleClickEnable(true).

Filed bug 179450 to track the API deprecation.
Comment 46 Dani Megert CLA 2007-03-28 03:12:06 EDT
Sorry, I have to reopen this bug. Either SWT forgot to submit to I20070327-0800 or the feature does not work.
Comment 47 Dani Megert CLA 2007-03-28 03:58:55 EDT
OK, I now downloaded and verified in N20070328-0010 where it works.

It would really be good if things that are marked with "fixed in HEAD > 20070326" would be available in the upcoming I-build (or at least a statement that it will not be) since most up-stream clients test/sit on the I-builds and not N-builds.
Comment 48 Dani Megert CLA 2007-03-28 03:59:27 EDT
Verified in N20070328-0010.
Comment 49 Sam Mesh CLA 2007-04-06 18:35:32 EDT
What about quadruple click?
Comment 50 Ed Burnette CLA 2007-04-09 09:19:18 EDT
Just don't click 13 times in a row while chanting "Bloody Mary"...
I can't say exactly what happens but you've seen "The Ring", right?
Comment 51 Steve Northover CLA 2007-04-09 11:23:11 EDT
This bug report is tracking triple click.