Mousewheel Paste in Godot Editor: How do I turn it off?

Godot Version

4.7

Question

In the Editor, a mousewheel click will paste the clipboard into my code. I don't use this and I often paste things I don't want with this feature on. But I can't find any place to turn it off. From reading the forums, I understand that this is only happens on Linux versions of Godot. But what I also know is that it isn't a linux or mint or x11 or wayland thing because godot is the only editor on my machine where this happens.

I’m pretty sure this is a Linux feature, not a “Linux version of godot” feature. I recommend googling how to turn the feature off in your specific Linux distribution. And I run Mint with X11, this feature is present everywhere in the OS, it is an OS feature. I’m not sure how you tested it.

it doesn’t happen in the linux terminal. I doesn’t happen in Xed. It doesn’t happen in JEdit. It doesn’t happen in LibreOffice. The only place i’ve ever seen it happen is in the Godot editor. And godot catches mouse and keyboard events so there must be a way to intercept it and turn it off.

Middle mouse paste is enabled by default and I can’t see a setting to disable it. You can make a plugin to disable it:

@tool
extends EditorPlugin


func _enter_tree() -> void:
	var editor = EditorInterface.get_script_editor()
	editor.editor_script_changed.connect(_on_script_changed)


func _exit_tree() -> void:
	var editor = EditorInterface.get_script_editor()
	if editor.editor_script_changed.is_connected(_on_script_changed):
		editor.editor_script_changed.disconnect(_on_script_changed)


func _on_script_changed(_script: Script) -> void:
	var current = EditorInterface.get_script_editor().get_current_editor()
	var text_editor = current.get_base_editor()
	if text_editor is TextEdit:
		text_editor.middle_mouse_paste_enabled = false

Yes, that is it! Thank you ! The problem comes from the fact that the editor’s CodeEdit elements inherit from TextEdit, but the editor doesn’t expose a setting to turn off TextEdit.middle_mouse_paste_enabled. You should put that addon in the Asset Library!

You should probably mark their answer as the solution if it helped you! It seems like a nice way to get around this problem.

wups i thought i did. I’m not familiar with this forum.