fix the pressing/hovering/tooltip interaction
This commit is contained in:
parent
37c4cbee74
commit
aa9577bfc7
|
@ -148,6 +148,15 @@ namespace winrt::TerminalApp::implementation
|
|||
// - button: the button that was hovered
|
||||
void MinMaxCloseControl::HoverButton(CaptionButton button)
|
||||
{
|
||||
// Keep track of the button that's been pressed. we get a mouse move
|
||||
// message when we open the tooltip. If we move the mouse on top of this
|
||||
// button, that we've already pressed, then no need to move to the
|
||||
// "hovered" state, we should stay in the pressed state.
|
||||
if (_lastPressedButton && _lastPressedButton.value() == button)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (button)
|
||||
{
|
||||
case CaptionButton::Minimize:
|
||||
|
@ -207,6 +216,7 @@ namespace winrt::TerminalApp::implementation
|
|||
VisualStateManager::GoToState(CloseButton(), L"Pressed", false);
|
||||
break;
|
||||
}
|
||||
_lastPressedButton = button;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
@ -222,5 +232,7 @@ namespace winrt::TerminalApp::implementation
|
|||
_closeToolTipForButton(MinimizeButton());
|
||||
_closeToolTipForButton(MaximizeButton());
|
||||
_closeToolTipForButton(CloseButton());
|
||||
|
||||
_lastPressedButton = std::nullopt;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace winrt::TerminalApp::implementation
|
|||
TYPED_EVENT(CloseClick, TerminalApp::MinMaxCloseControl, winrt::Windows::UI::Xaml::RoutedEventArgs);
|
||||
|
||||
std::shared_ptr<ThrottledFuncTrailing<winrt::Windows::UI::Xaml::Controls::Button>> _displayToolTip{ nullptr };
|
||||
std::optional<CaptionButton> _lastPressedButton{ std::nullopt };
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ namespace winrt::TerminalApp::implementation
|
|||
|
||||
double TitlebarControl::CaptionButtonWidth()
|
||||
{
|
||||
// Divide by three, since we know there are only three buttons. When
|
||||
// Windows 12 comes along and adds another, we can update this /s
|
||||
static double width{ MinMaxCloseControl().ActualWidth() / 3.0 };
|
||||
return width;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue