Double-click selection option

SyntaxEditor for Windows Forms Forum

Posted 20 years ago by Marianne
Avatar
Can you add an option so that when double-clicking text inside the editor, that instead of highlighting just the word, the entire current token is highlighted instead?

------------------------------- Marianne

Comments (9)

Posted 20 years ago by Boyd - Sr. Software Developer, Patterson Consulting, LLC
Avatar
This would actually make a nice "triple-click" feature as well.
Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
How would you like to see things set up... we can either make some sort of cancellable double-click event that if cancelled, would not do typical word selection. Or we can expose some sort of a triple-click event.

In either case, we'd only need this when the mouse is over text, right? So we could pass in the Token that was clicked?


Actipro Software Support

Posted 20 years ago by Boyd - Sr. Software Developer, Patterson Consulting, LLC
Avatar
Maybe this is partially solved by the changes already being made for SE 3.0. If I recall correctly, SE 3.0 has a TokenClick event. You could pass a value in the EventArgs to indicate how many successive clicks have been made on the Token (i.e. 1, 2, 3) and the programmer can handle it accordingly. This would be cleaner than having "TokenClick", "TokenDoubleClick", and "TokenTripleClick" events. This approach would require the ability to cancel the standard word-select from a DoubleClick, so you'd need to expose a method to cancel the default behavior.

I like this approach, but I'll let Marianne comment futher since I didn't post the original request.
Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Yes, excellent observation... the new TokenMouseDown event passes a Clicks parameter. That parameter will be altered to indicate the number of successive mouse downs that occur in a row.

So something like this would let you cancel the default double-click behavior and add your own handling:
if (e.Clicks == 2) {
    e.Cancel = true;
    // TODO: Do custom selection or other task instead of selecting a word
}


Actipro Software Support

Posted 20 years ago by Marianne
Avatar
Yes, that is more than workable. Just one question. Does the clicks parameter indicate the number of mouse-downs as part of a single event or does it continue to add them together. In other words, if a user clicked once, then waited, then clicked once again without moving the mouse, the clicks parameter in both cases should be one, correct?

Also, I would assume that another parameter of the TokenMouseDown event would be the actual token that was clicked on. If not, can it be added? Thanks.

------------------------------- Marianne

Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
The Clicks property indicates how many successive clicks there were. As soon as a click is not within the system-defined double-click time of the last click, the Clicks resets to 1.

And yes, the Token that was clicked is passed in the event args as well.

There also are new events for hovering over a token, moving the mouse over a token, and moving the mouse out of a token.


Actipro Software Support

Posted 20 years ago by Marianne
Avatar
Then the currently planned implementation seems to be the most robust. This is actually a lot better than just adding a double-click option to select the token since we'll have the ultimate control on how to handle the events.

Thanks much!

------------------------------- Marianne

Posted 18 years ago by Thomas Goff
Avatar
What would be the best way to select the token in the TokenMouseDown event?
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
if (e.Clicks == 2) {
    e.Cancel = true;
    editor.SelectedView.Selection.SelectRange(e.Token.StartOffset, e.Token.Length);
}


Actipro Software Support

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.