Git Product home page Git Product logo

Comments (9)

jacobslusser avatar jacobslusser commented on August 28, 2024

I haven't specifically implemented Drag & Drop in ScintillaNET v3 yet and based on your experience, it doesn't look like we're getting it for free from Windows Forms. Let me investigate and get back to you.

from scintillanet.

jacobslusser avatar jacobslusser commented on August 28, 2024

So I'm looking into this a bit and I don't seem to have any problems dragging items from a TreeView to ScintillaNET.

Is the issue that you can't drag items from the TreeView to ScintillaNET? Or is the issue that some of the events are not firing?

from scintillanet.

ZaltaisHornblend avatar ZaltaisHornblend commented on August 28, 2024

Thank you for your answers.

My issue is that DragEnter event and DragDrop event does not fire.
With visual studio I debug my application and I see that the ItemDrag event fires but not the other two.
After taking a node in the TreeView and I move my mouse in the control ScintillaNet nothing happens. The mouse cursor tells me I can not. I took a screenshot to be more clear.

scintilladragdrop

I know the Drag & Drop event is inherited from Windows.Forms and I don't understand why it's not working.
my code :

// TreeView ItemDrag
private void treeView1_ItemDrag(object sender, ItemDragEventArgs e) {
treeView1.DoDragDrop(e.Item, DragDropEffects.All);
}

// ScintillaNET events
private void scintilla1_DragEnter(object sender, DragEventArgs e) {
e.Effect = DragDropEffects.Copy;
}

private void scintilla1_DragDrop(object sender, DragEventArgs e) {
if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false))
{
scintilla1.Text = scintilla1.Text.Insert(1, ((TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode")).Text);
}
}

from scintillanet.

ZaltaisHornblend avatar ZaltaisHornblend commented on August 28, 2024

I just do some additional tests. I just noticed that the problem is not the Drag & Drop.
Indeed, I tried to implement the click event and other event and they too do not fire.

So the origin of my issue is elsewhere... Something has to interfere with the correct operation of ScintillaNET. Any ideas ?

I'll get ... and I hope to find.

Thank you for your time. I appreciate.

from scintillanet.

jacobslusser avatar jacobslusser commented on August 28, 2024

Try:

private void treeView1_ItemDrag(object sender, ItemDragEventArgs e)
{
    treeView1.DoDragDrop(((TreeNode)e.Item).Text, DragDropEffects.Copy);
}

I have a pretty good idea why the Drag events aren't firing as you expect, but this should get you what you want for now.

BTW - Scintilla events are different from standard Windows Forms control events. Version 3 of ScintillaNET tries to recognize and accept that fact. It isn't a standard Windows Forms control so we shouldn't treat it as such. That being said, I'll see what I can do. :)

from scintillanet.

jacobslusser avatar jacobslusser commented on August 28, 2024

I remember fixing this exact issue in ScintillaNET v2.x so I knew where to look. The issue is that the native Scintilla control automatically registers itself as a drag and drop target before the Windows Forms framework does. The result is that the native Scintilla control handles the drag and drop events instead of raising the Windows Forms DragEnter, DragDrop, etc... events. The fix I decided to go with was to revoke drag and drop support after the native Scintilla control is created but before the Windows Forms framework does registration so that Windows Forms still thinks it is the first one to the party when it registers the control.

Unfortunately this means the built-in support that the native Scintilla control already has is no longer being used. It puts a larger burden on ScintillaNET developers to handle the drag and drop events, but it allows more flexibility and so I think it's the right thing to do.

from scintillanet.

ZaltaisHornblend avatar ZaltaisHornblend commented on August 28, 2024

Okay I understand your explanation.

I tried your code and changed my event as you have indicated above me. Now my Drag & Drop works well.

Thank you for the solution and for your time. :)
The Scintilla project is impressive. 👍

from scintillanet.

jacobslusser avatar jacobslusser commented on August 28, 2024

P.S. Commit 02336ec adds support for CharPositionFromPoint[Close], PointXFromPosition, and PointYFromPosition methods which make it possible to convert mouse coordinates to document positions and vice versa.

This should help you identify the proper document and caret position in your drag and drop operations.

from scintillanet.

ZaltaisHornblend avatar ZaltaisHornblend commented on August 28, 2024

These methods save my life, thank you ! :)

from scintillanet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.