# How to create a Listener for dragAndDrop on an editorTab

**URL:** <https://platform.jetbrains.com/t/how-to-create-a-listener-for-draganddrop-on-an-editortab/1050>\
**Category:** IntelliJ Platform\
**Created:** [March 22, 2025, 2:52pm UTC](https://platform.jetbrains.com/t/how-to-create-a-listener-for-draganddrop-on-an-editortab/1050 "2025-03-22T14:52:24Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![phanthaiduong22](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/phanthaiduong22/32/488_2.png) [@phanthaiduong22](https://platform.jetbrains.com/u/phanthaiduong22)\
**Post date:** [March 22, 2025, 2:52pm UTC](https://platform.jetbrains.com/t/how-to-create-a-listener-for-draganddrop-on-an-editortab/1050/1 "2025-03-22T14:52:24Z")

</div>

Hi team, I would like to listen for the `dragAndDrop` event of an editor tab when it is being dragged or dropped.

How can I achieve this?

Thank you.

 ![image](https://us1.discourse-cdn.com/flex001/uploads/jetbrains_platform/original/1X/27902acad8472e663a86df5532070e5330cd177e.png)

---

<div class="post-metadata">

**Author:** ![chriscarini](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/chriscarini/32/695_2.png) [@chriscarini](https://platform.jetbrains.com/u/chriscarini)\
**Post date:** [March 22, 2025, 7:48pm UTC](https://platform.jetbrains.com/t/how-to-create-a-listener-for-draganddrop-on-an-editortab/1050/3 "2025-03-22T19:48:17Z")

</div>

Check out `com.intellij.fileDropHandler`:

- [https://jb.gg/ipe?extensions=com.intellij.fileDropHandler](https://jb.gg/ipe?extensions=com.intellij.fileDropHandler)
- [intellij-community/platform/platform-impl/src/com/intellij/openapi/editor/FileDropHandler.kt at idea/243.26053.27 · JetBrains/intellij-community · GitHub](https://github.com/JetBrains/intellij-community/blob/idea/243.26053.27/platform/platform-impl/src/com/intellij/openapi/editor/FileDropHandler.kt)

---

<div class="post-metadata">

**Author:** ![phanthaiduong22](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/phanthaiduong22/32/488_2.png) [@phanthaiduong22](https://platform.jetbrains.com/u/phanthaiduong22)\
**Post date:** [March 23, 2025, 3:20am UTC](https://platform.jetbrains.com/t/how-to-create-a-listener-for-draganddrop-on-an-editortab/1050/4 "2025-03-23T03:20:58Z")

</div>

Thank you for your reply.

I just tried using this interface. It looks like it can detect files being dropped (e.g., from the desktop into the IDE). However, when I try to drag and drop an active editor that is open in IntelliJ (e.g., when splitting the editor window), no events are captured.

---

<div class="post-metadata">

**Author:** ![chriscarini](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/chriscarini/32/695_2.png) [@chriscarini](https://platform.jetbrains.com/u/chriscarini)\
**Post date:** [March 23, 2025, 5:00am UTC](https://platform.jetbrains.com/t/how-to-create-a-listener-for-draganddrop-on-an-editortab/1050/5 "2025-03-23T05:00:22Z")

</div>

Hi @phanthaiduong22 - ah my apologies, I misunderstood! I’ve actually been trying to do something similar, but I’ve been looking/trying via a very low-level interface; an awt listener. It gets a ton of events, and I haven’t been able to pin down the exact filter yet to catch the event for this though. If you think it’d be helpful, I can dig it up and share

---

<div class="post-metadata">

**Author:** ![phanthaiduong22](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/phanthaiduong22/32/488_2.png) [@phanthaiduong22](https://platform.jetbrains.com/u/phanthaiduong22)\
**Post date:** [March 23, 2025, 5:35am UTC](https://platform.jetbrains.com/t/how-to-create-a-listener-for-draganddrop-on-an-editortab/1050/6 "2025-03-23T05:35:16Z")

</div>

Yeah, Chris, I think it would be helpful as well. Could you share it? I will also take a look at how to filter drag-and-drop events from an active editor based on what you shared.

Additional information: I can use: `java.awt.dnd.DropTargetAdapter` to listen drag and drop events from projectTree, or files from commit tab. However, when I tried drag and drop an active editor file, it can’t listen.

---

<div class="post-metadata">

**Author:** ![phanthaiduong22](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/phanthaiduong22/32/488_2.png) [@phanthaiduong22](https://platform.jetbrains.com/u/phanthaiduong22)\
**Post date:** [March 23, 2025, 7:54am UTC](https://platform.jetbrains.com/t/how-to-create-a-listener-for-draganddrop-on-an-editortab/1050/7 "2025-03-23T07:54:14Z")

</div>

When I use debug mode.

I notice [intellij-community/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorTabbedContainer.kt at 468d9bd86c6065a31d78bfbcc9bc08c0af80d07c · JetBrains/intellij-community · GitHub](https://github.com/JetBrains/intellij-community/blob/468d9bd86c6065a31d78bfbcc9bc08c0af80d07c/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorTabbedContainer.kt#L410)

being triggered. But not sure if we can use similar to this.

---

<div class="post-metadata">

**Author:** ![yann.cebron](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/yann.cebron/32/15_2.png) [@yann.cebron](https://platform.jetbrains.com/u/yann.cebron)\
**Post date:** [March 24, 2025, 9:36am UTC](https://platform.jetbrains.com/t/how-to-create-a-listener-for-draganddrop-on-an-editortab/1050/9 "2025-03-24T09:36:59Z")

</div>

> I would like to listen for the `dragAndDrop` event of an editor tab when it is being dragged or dropped

What is the use case?

---

<div class="post-metadata">

**Author:** ![phanthaiduong22](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/phanthaiduong22/32/488_2.png) [@phanthaiduong22](https://platform.jetbrains.com/u/phanthaiduong22)\
**Post date:** [March 24, 2025, 10:14am UTC](https://platform.jetbrains.com/t/how-to-create-a-listener-for-draganddrop-on-an-editortab/1050/10 "2025-03-24T10:14:14Z")

</div>

> [@yann.cebron](#):
>
> What is the use case?

Hi @yann.cebron use case is developing a chat with an LLM feature, and I want to drag and drop an editor tab into the chat for reference.

---

<div class="post-metadata">

**Author:** ![chriscarini](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/chriscarini/32/695_2.png) [@chriscarini](https://platform.jetbrains.com/u/chriscarini)\
**Post date:** [March 27, 2025, 5:27am UTC](https://platform.jetbrains.com/t/how-to-create-a-listener-for-draganddrop-on-an-editortab/1050/12 "2025-03-27T05:27:05Z")

</div>

@phanthaiduong22 - I’m starting to think this might not be possible, without some guidance or code changes from JetBrains.

Specifically, I tried adding a `java.awt.event.AWTEventListener` with a mask of `AWTEvent.MOUSE_EVENT_MASK` (I’m 99% confident this is the correct mask), and I get all the mouse events I’d expect, _ **but** _ when dragging tabs and releasing in a new position (I’m also seeing `EditorTabbedContainerDragOutDelegate` fwiw, so I think we’re both on the right track), it seems like something is consuming the event and the listener I created is not getting called.

_(A few days later…)_

After typing the above, and hacking around the code a bit more, I was able to get a _bit_ further, but not by much. I was able to get a mouse listener added, with a lower ‘weight’ (so it would get called before whichever listener was consuming the event mentioned above), but now I’m struggling to figure out if the `java.awt.event.MouseEvent` is coming from a ‘drag and drop’ type ‘mouse event’, or if its something else.

---

<div class="post-metadata">

**Author:** ![chriscarini](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/chriscarini/32/695_2.png) [@chriscarini](https://platform.jetbrains.com/u/chriscarini)\
**Post date:** [April 8, 2025, 12:48am UTC](https://platform.jetbrains.com/t/how-to-create-a-listener-for-draganddrop-on-an-editortab/1050/13 "2025-04-08T00:48:02Z")

</div>

I just saw [GitHub - MikSuki/TabSplitter](https://github.com/MikSuki/TabSplitter) plugin in marketplace, and thought it _might_ have some code that may help here.

I haven’t had a chance to look into any of this further, but @phanthaiduong22 if you happen to be looking still, perhaps this repo/plugin might have something of interest?

---

<div class="post-metadata">

**Author:** ![phanthaiduong22](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/phanthaiduong22/32/488_2.png) [@phanthaiduong22](https://platform.jetbrains.com/u/phanthaiduong22)\
**Post date:** [April 8, 2025, 2:37pm UTC](https://platform.jetbrains.com/t/how-to-create-a-listener-for-draganddrop-on-an-editortab/1050/14 "2025-04-08T14:37:35Z")

</div>

Yeah, I just had a quick look at the source code. It looks like it has `fileClosed` or `fileSelectionChange` listeners, but it doesn’t have a drag-and-drop file listener.

---

<div class="post-metadata">

**Author:** ![phanthaiduong22](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/phanthaiduong22/32/488_2.png) [@phanthaiduong22](https://platform.jetbrains.com/u/phanthaiduong22)\
**Post date:** [July 24, 2025, 10:05am UTC](https://platform.jetbrains.com/t/how-to-create-a-listener-for-draganddrop-on-an-editortab/1050/15 "2025-07-24T10:05:12Z")

</div>

Hi @chriscarini @yann.cebron, do you know if there are any plans for JetBrains to support this?

---

<div class="post-metadata">

**Author:** ![yuriy.artamonov](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/yuriy.artamonov/32/48_2.png) [@yuriy.artamonov](https://platform.jetbrains.com/u/yuriy.artamonov)\
**Post date:** [July 24, 2025, 10:19am UTC](https://platform.jetbrains.com/t/how-to-create-a-listener-for-draganddrop-on-an-editortab/1050/16 "2025-07-24T10:19:35Z")

</div>

At the moment we have no such work planned
