X Tutup
Skip to content

Make minimum drag distance configurable for gui elements#110245

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
Armynator:add-min-gui-drag-distance
Oct 27, 2025
Merged

Make minimum drag distance configurable for gui elements#110245
Repiteo merged 1 commit intogodotengine:masterfrom
Armynator:add-min-gui-drag-distance

Conversation

@Armynator
Copy link
Contributor

The minimum mouse drag distance for gui elements is currently hardcoded to 10, making it feel quite unresponsive to me. In Unity it's 5 by default and can be configured. Today I've learned that I'm not the only one having issues with it, making me wonder if there was a reason to hardcode it in the first place?

This PR turns it into a project setting, keeping the default value at 10. Also it's only used when running the game, so the editor behavior doesn't change even when adjusting the value.

It might be more useful to make this configurable per-viewport, but this version seems easier to use and understand.
(In Unity it's set in the EventSystem class (pixelDragThreshold), which usually only exists once in the scene as well)

In my specific case it allows me to use a TabBar also as a drag panel header for a scripted game window without feeling unresponsive

Default behavior (drag distance 10, window drag script distance 6):

drag_10.webm

(The window gets dragged for a moment as the NOTIFICATION_DRAG_BEGIN isn't fired by the TabBar yet)

Setting minimum drag distance to 5 (window drag script distance still 6):

drag_5.webm

(NOTIFICATION_DRAG_BEGIN is fired sooner, blocking the window movement script until NOTIFICATION_DRAG_END)

And I assume there are more use cases for this, as you can do quite a few things with the integrated drag & drop system...

@Armynator Armynator requested review from a team as code owners September 4, 2025 05:41
@AdriaandeJongh
Copy link
Contributor

this is fantastic UX work! i’d love to get this approved.

@AThousandShips AThousandShips added this to the 4.x milestone Sep 4, 2025
@AThousandShips AThousandShips changed the title make minimum drag distance configurable for gui elements Make minimum drag distance configurable for gui elements Sep 4, 2025
Copy link
Member

@bruvzg bruvzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good UI improvement.

I think making it a Viewport property would be more convenient, the project setting still can be used for default viewport, add set here:

godot/main/main.cpp

Lines 4475 to 4476 in 6c9aa4c

bool font_oversampling = GLOBAL_GET("gui/fonts/dynamic_fonts/use_oversampling");
sml->get_root()->set_use_oversampling(font_oversampling);

@Armynator
Copy link
Contributor Author

I think making it a Viewport property would be more convenient, the project setting still can be used for default viewport, add set here:

TY for pointing me there! I've done as you recommended now as it indeed has some advantages:

  • the drag threshold is adjustable at runtime for every Viewport by script
  • the drag threshold value for every SubViewport is adjustable in the editor inspector
  • the value for the default Viewport is still easily adjustable in the project settings

@Repiteo Repiteo modified the milestones: 4.x, 4.6 Sep 10, 2025
@Repiteo
Copy link
Contributor

Repiteo commented Oct 24, 2025

Could you rebase your PR? See our pull request guidelines for more information

@Repiteo Repiteo merged commit 08db7dd into godotengine:master Oct 27, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Oct 27, 2025

Thanks! Congratulations on your first merged contribution! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

X Tutup