Coder Social home page Coder Social logo

Exclusive mouse control to imgui about imgui HOT 3 OPEN

vescodes avatar vescodes commented on July 30, 2024
Exclusive mouse control to imgui

from imgui.

Comments (3)

VesCodes avatar VesCodes commented on July 30, 2024

Hey Arnaud, sorry for taking so long to respond! Work got busy with the run-up to the holidays.

One of my goals was to keep the public API as concise as possible so I kind of settled with Unreal's built-in mechanisms where I could. The input processor only pipes through mouse moves to ImGui when no other widget has mouse capture - this functionality should technically cover points 1 and 2 as users can swap between UI and Game input modes to effectively enable/disable ImGui input handling respectively.

For point 3 I think your first approach sounds reasonable, you could expose an ImGui extension method like the following:

IMGUI_API void SetExclusiveMouseMode(bool bValue)
{
	const TSharedPtr<FImGuiContext> Context = FImGuiContext::Get(GetCurrentContext());
	if (Context.IsValid())
	{
		Context->ExclusiveMouseMode = bValue;
	}
}

I'll consider adding this functionality in some form with some other incoming changes :)

from imgui.

arnaud-jamin avatar arnaud-jamin commented on July 30, 2024

No problem. I've been trying to use the input processor too, but didn't find a way to not block editor inputs. Like pressing the stop button. I've switched back to using the input received by the widget, but i still don't know how to properly handle a shared mouse between the game and imgui.

from imgui.

Wyverex42 avatar Wyverex42 commented on July 30, 2024

I have a similar issue at the moment where I have an in-game map view and I render a bunch of ImGui on top. Whenever I hold the middle mouse button to drag the map, afterwards ImGui doesn't receive any further mouse move events. I tracked this down to

	virtual bool HandleMouseMoveEvent(FSlateApplication& SlateApp, const FPointerEvent& Event) override
	{
               [...]
		if (SlateApp.HasAnyMouseCaptor())
		{
			IO.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
			return false;
		}

I first have to click once anywhere using the left mouse button to make it work again. So apparently when dragging with any mouse button, the Slate window captures the mouse which then ends in this early-out.

I basically want option 2 in the OP's post and I need to have both input for the game and ImGui available, depending on where the mouse is.
I'm not sure now whether the solution should be to make the Slate window not capture the mouse (not sure how to) or whether this should be an option in the ImGui plugin which then basically skips this check. Any recommendations?

from imgui.

Related Issues (8)

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.