Slate mouse click response time SLOW

I am facing a serious issue.

I got a border widget and I detect when mouse is button is pressed on it.
Something like this


SNew(SBorder)// Has On Hover that changes the outline, has methods to change the 
				.Padding(FMargin(0, 0, 4.2, 2))
				.BorderImage(&InvStorage->NothingCursor)
				.HAlign(HAlign_Right)
				.VAlign(VAlign_Bottom)
				.OnMouseButtonDown(this, &SItemWidget::OnItemPressed)
				.OnMouseButtonUp(this, &SItemWidget::OnItemReleased)

And when detected I do something like this…



FReply SItemWidget::OnItemPressed(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
GEngine->AddOnScreenDebugMessage(-1, 3.0f, FColor::Blue, "Click");
	if (IsEnabled())
	{
		if (MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton)
		{
			GEngine->AddOnScreenDebugMessage(-1, 3.0f, FColor::Blue, "LeftClick");
			InvStorage->LeftClick(SlotLoc.Get());
			bUpDownLeftClick = true;
		}
		else if (MouseEvent.GetEffectingButton() == EKeys::RightMouseButton)
		{
			InvStorage->RightClick(SlotLoc.Get());
		}
	}
	return FReply::Handled();
}

The problem is the slate cannot detect fast clicks…

Like if I click that icon 2-3 times very fast, only 1 click is being registered? But if i click it with some time separation in between, it works fine.

edit, i did some testing and found out that after 1 click, it acts as if the slate menu is not present in that place a few miliseconds.

Sounds like your widget might stop accepting clicks for a little bit, or some other widget is intercepting them.

SlateApplication has some very verbose logging you can use to know what is handling any given Slate input event. You can enable it by changing a define in SlateApplication.cpp:


#define LOG_SLATE_EVENTS 1

Note that this logging apparently hasn’t been used in a while because I had to fix a few (very simple) compilation errors when turning it on. This might’ve been fixed since 4.5. Once you have the logging macro set up, add a logger somewhere in your code:


#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
	FSlateApplication::Get().SetSlateUILogger( MakeShareable( new FConsoleEventLogger() ) );
#endif

This will make Slate spew a lot of output (because of high frequence events like MouseMove) into the output log. Just try your clicks and see who is responding after the first one.


1>D:\Unreal Engine Launcher\4.6.1\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp(2929): error C2065: 'Event' : undeclared identifier
1>D:\Unreal Engine Launcher\4.6.1\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp(2939): error C2668: 'LogSlateEvent' : ambiguous call to overloaded function
1>          D:\Unreal Engine Launcher\4.6.1\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp(290): could be 'void LogSlateEvent(const TSharedPtr<IEventLogger,0> &,EEventLog::Type,const FString &,const FReply &)'
1>          D:\Unreal Engine Launcher\4.6.1\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp(282): or       'void LogSlateEvent(const TSharedPtr<IEventLogger,0> &,EEventLog::Type,const FString &,const TSharedPtr<SWidget,0> &)'
1>          while trying to match the argument list '(TSharedPtr<IEventLogger,0>, EEventLog::Type, const FString, int)'
1>D:\Unreal Engine Launcher\4.6.1\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp(3472): error C2228: left of '.ToString' must have class/struct/union
1>          type is 'unknown-type'
1>D:\Unreal Engine Launcher\4.6.1\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp(3472): error C2661: 'LogSlateEvent' : no overloaded function takes 3 arguments
1>D:\Unreal Engine Launcher\4.6.1\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp(3472): error C3861: 'GetKeyName': identifier not found
1>D:\Unreal Engine Launcher\4.6.1\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp(3513): error C2228: left of '.ToString' must have class/struct/union
1>          type is 'unknown-type'
1>D:\Unreal Engine Launcher\4.6.1\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp(3513): error C2661: 'LogSlateEvent' : no overloaded function takes 3 arguments
1>D:\Unreal Engine Launcher\4.6.1\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp(3513): error C3861: 'GetKeyName': identifier not found
1>D:\Unreal Engine Launcher\4.6.1\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp(3540): error C2228: left of '.ToString' must have class/struct/union
1>          type is 'unknown-type'
1>D:\Unreal Engine Launcher\4.6.1\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp(3540): error C2661: 'LogSlateEvent' : no overloaded function takes 3 arguments
1>D:\Unreal Engine Launcher\4.6.1\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp(3540): error C3861: 'GetKeyName': identifier not found
1>D:\Unreal Engine Launcher\4.6.1\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp(3983): error C2065: 'bIsGestureEvent' : undeclared identifier
1>D:\Unreal Engine Launcher\4.6.1\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp(3983): error C2661: 'LogSlateEvent' : no overloaded function takes 3 arguments

Got a lot of errors on enabling it…

I got something like this in my playercontroller


void ATestPlayerController::LeftClickPressed()
{
	GEngine->AddOnScreenDebugMessage(-1, 3.0f, FColor::Green, "LeftClick");
}

This doesn’t work when a slate input is handled.

But when i click on a slate border 2 times I see the slate button trigger once and this trigger once.

----------------------------- EDIT ----------------------------------
Solved

The problem is how slate double click works…

I did something like this


FReply SItemWidget::OnDoubleClick(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
	if (IsEnabled())
	{
		if (MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton)
		{
			GEngine->AddOnScreenDebugMessage(-1, 3.0f, FColor::Blue, "LeftClick");
		}
	}
	return FReply::Handled();
}

And the second click is triggering the double click…

In case there are a quick succession of clicks, the double click gets triggered. This replaces the


.OnMouseButtonDown(

event. I don’t know if there is a way to disable it. But i guess this works for me.

Keep in mind this just replaces the mouse down event. There is no problems with the mouse up event.

That’s “a lot of errors”? You must find engine integrations fun! :wink: I guarantee you those can be fixed in 3-5 minutes tops and slate logging has helped me a LOT.

Slate double click events are finnicky. I don’t recall the specifics, but I recall it getting intercepted by a parent widget that was handling MouseUp. It might be that a combination of handling/not handling MouseUp might help. (Remember you can still do logic without returning FReply::Handled!) I’d try to dig it up but I’m a bit swamped with final preparations for PAX East.

Well not a lot of errors actually :stuck_out_tongue: I didn’t knew we had to solve them to make it work…

Yes, its due to the double click. Tried Unhandled double clicks but still didn’t work. Although i made it work by passing the double click to the single click function.

Had the same issue with slate when clicking on FEditorViewportClient but solved it by not using the ProcessClick funtions but instead I did override “InputKey” function which directly responds to any clicks.