Drag & Drop - Get Text and/or Position when hovering

SyntaxEditor for Windows Forms Forum

Posted 15 years ago by Michael Maes
Avatar
Hi,

I've subclassed the Editor to raise the 'standard' D&D-Events.
Those work as I like now.

The next issue I stumbled upon is how to determine the position where the Cursor (dragging) is over and what the 'underlying' text is.
Some controls have Functions like: 'GetRowAt', 'GetAppointmentAt', ...
I've searched the forum, but I haven't been able to find a solution to my needs.

Bottomline: I need the Word under the Cursor while dragging over the Editor. This in a perpetual way (so if i drag over a sentence, i get every word sepparate).

Thanks,

Michael

Comments (3)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Check out EditorView.OffsetFromLocation. That allows you to pass in client coords and get the offset under it.


Actipro Software Support

Posted 15 years ago by Michael Maes
Avatar
I'm sorry, could you please post an example. I allready had tried
Quote:
<font size="1" face="Verdana, Arial">quote:</font><HR> Debug.WriteLine(sedOutput.Views(0).OffsetFromLocation(New Point(e.X, e.Y), ActiproSoftware.SyntaxEditor.LocationToOffsetAlgorithm.Absolute))
Debug.WriteLine(sedOutput.Views(0).OffsetFromLocation(sedOutput.MousePosition, ActiproSoftware.SyntaxEditor.LocationToOffsetAlgorithm.Absolute))
<HR>
but that didn't work (always -1).

Could you also include a snippet to get the word on that location please.

Thanks!

Michael

PS: I also saw 'editor.Document.CurrentView.OffsetFromLocation' a couple of times on the forum. Is CurrentView obsolete because I have no such memeber in 'Document'. (I have v2.5.151.0)
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Yes, it's now SelectedView.

So you'd do something like this:

sedOutput.SelectedView.OffsetFromLocation(New Point(e.X, e.Y), ActiproSoftware.SyntaxEditor.LocationToOffsetAlgorithm.BestFit)

Also, read the documentation on the LocationToOffsetAlgorithm enumeration. There are three values and each of them do different things. Absolute returns -1 if you are not over an offset at all. The other two will attempt to find which offset you are closest to if you are not over one.

[ 03-16-2005: Message edited by: Actipro Software Support ]


Actipro Software Support

The latest build of this product (v2020.1 build 0400) was released 2 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.