背景
菜单栏点击最小化事件,产生了哪些操作,如何自己实现最小化功能,直接上代码
窗口最小化代码
Engine\Source\Runtime\Slate\Public\Framework\Application\SWindowTitleBar.h
FReply MinimizeButton_OnClicked( )
{
TSharedPtr<SWindow> OwnerWindow = OwnerWindowPtr.Pin();
if (OwnerWindow.IsValid())
{
TSharedPtr<FGenericWindow> NativeWindow = OwnerWindow->GetNativeWindow();
if (NativeWindow.IsValid())
{
NativeWindow->Minimize();
}
}
return FReply::Handled();
}
最小化窗口以后,做了这个操作return FReply::Handled();
/**
* An event should return a FReply::Handled() to let the system know that an event was handled.
*/
static FReply Handled( )
{
return FReply(true);
}
/**
* Hidden default constructor.
*/
FReply( bool bIsHandled )
: TReplyBase<FReply>(bIsHandled)
, RequestedMousePos()
, EventHandler(nullptr)
, MouseCaptor(nullptr)
, FocusRecipient(nullptr)
, MouseLockWidget(nullptr)
, DetectDragForWidget(nullptr)
, NavigationDestination(nullptr)
, DragDropContent(nullptr)
, FocusChangeReason(EFocusCause::SetDirectly)
, NavigationType(EUINavigation::Invalid)
, NavigationGenesis(ENavigationGenesis::User)
, NavigationSource(ENavigationSource::FocusedWidget)
, bReleaseMouseCapture(false)
, bSetUserFocus(false)
, bReleaseUserFocus(false)
, bAllUsers(false)
, bShouldReleaseMouseLock(false)
, bUseHighPrecisionMouse(false)
, bPreventThrottling(false)
, bEndDragDrop(false)
{ }
//If the user hasn't requested a new mouse captor and the button still has mouse capture,
//then the default behavior of the button is to release mouse capture.
if ( Reply.GetMouseCaptor().IsValid() == false && HasMouseCapture() )
{
Reply.ReleaseMouseCapture();
}
/**
* An event should return a FReply::Handled().ReleaseMouse() to ask the system to release mouse capture
* NOTE: Deactivates high precision mouse movement if activated.
*/
FReply& ReleaseMouseCapture()
{
this->MouseCaptor.Reset();
this->bReleaseMouseCapture = true;
this->bUseHighPrecisionMouse = false;
return Me();
}
bool FSlateApplication::ProcessMouseButtonUpEvent( const FPointerEvent& MouseEvent )
{
SCOPE_CYCLE_COUNTER(STAT_ProcessMouseButtonUp);
#if WITH_SLATE_DEBUGGING
FSlateDebugging::FScopeProcessInputEvent Scope(ESlateDebuggingInputEvent::MouseButtonUp, MouseEvent);
#endif
// If in responsive mode throttle, leave it on mouse up. Release this before dispatching the event to prevent being stuck in this mode
// until the next click if a modal dialog is opened.
if (MouseButtonDownResponsivnessThrottle.IsValid())
{
FSlateThrottleManager::Get().LeaveResponsiveMode(MouseButtonDownResponsivnessThrottle);
}
SetLastUserInteractionTime(this->GetCurrentTime());
LastUserInteractionTimeForThrottling = LastUserInteractionTime;
const bool bIsCursorUser = MouseEvent.GetUserIndex() == CursorUserIndex;
if (bIsCursorUser)
{
PressedMouseButtons.Remove(MouseEvent.GetEffectingButton());
}
// Input preprocessors get the first chance at the input
if (InputPreProcessors.HandleMouseButtonUpEvent(*this, MouseEvent))
{
return true;
}
// An empty widget path is passed in. As an optimization, one will be generated only if a captured mouse event isn't routed
FWidgetPath EmptyPath;
const bool bHandled = RoutePointerUpEvent( EmptyPath, MouseEvent ).IsEventHandled();
if ( bIsCursorUser && PressedMouseButtons.Num() == 0 )
{
PlatformApplication->SetCapture( nullptr );
}
return bHandled;
}