fix the pressing/hovering/tooltip interaction

This commit is contained in:
Mike Griese 2021-11-16 12:49:23 -06:00
parent 37c4cbee74
commit aa9577bfc7
3 changed files with 15 additions and 0 deletions

View file

@ -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;
}
}

View file

@ -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 };
};
}

View file

@ -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;
}