Only one tooltip at a time please
This commit is contained in:
parent
953620669d
commit
0fa10cd3ef
|
@ -20,7 +20,6 @@ namespace winrt::TerminalApp::implementation
|
|||
MinMaxCloseControl::MinMaxCloseControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
_MinimizeToolTip = RS_(L"WindowMinimizeButtonToolTipText");
|
||||
}
|
||||
|
||||
// These event handlers simply forward each buttons click events up to the
|
||||
|
@ -97,6 +96,17 @@ namespace winrt::TerminalApp::implementation
|
|||
}
|
||||
}
|
||||
|
||||
void _openToolTipForButton(const Controls::Button& button, const bool isOpen)
|
||||
{
|
||||
if (auto tt{ Controls::ToolTipService::GetToolTip(button) })
|
||||
{
|
||||
if (auto tooltip{ tt.try_as<Controls::ToolTip>() })
|
||||
{
|
||||
tooltip.IsOpen(isOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MinMaxCloseControl::HoverButton(CaptionButton button)
|
||||
{
|
||||
switch (button)
|
||||
|
@ -105,48 +115,29 @@ namespace winrt::TerminalApp::implementation
|
|||
VisualStateManager::GoToState(MinimizeButton(), L"PointerOver", false);
|
||||
VisualStateManager::GoToState(MaximizeButton(), L"Normal", false);
|
||||
VisualStateManager::GoToState(CloseButton(), L"Normal", false);
|
||||
if (auto tt{ Controls::ToolTipService::GetToolTip(MinimizeButton()) })
|
||||
{
|
||||
if (auto tooltip{ tt.try_as<Controls::ToolTip>() })
|
||||
{
|
||||
tooltip.IsOpen(true);
|
||||
}
|
||||
}
|
||||
|
||||
_openToolTipForButton(MinimizeButton(), true);
|
||||
_openToolTipForButton(MaximizeButton(), false);
|
||||
_openToolTipForButton(CloseButton(), false);
|
||||
break;
|
||||
case CaptionButton::Maximize:
|
||||
VisualStateManager::GoToState(MinimizeButton(), L"Normal", false);
|
||||
VisualStateManager::GoToState(MaximizeButton(), L"PointerOver", false);
|
||||
VisualStateManager::GoToState(CloseButton(), L"Normal", false);
|
||||
if (auto tt{ Controls::ToolTipService::GetToolTip(MaximizeButton()) })
|
||||
{
|
||||
if (auto tooltip{ tt.try_as<Controls::ToolTip>() })
|
||||
{
|
||||
tooltip.IsOpen(true);
|
||||
}
|
||||
}
|
||||
_openToolTipForButton(MinimizeButton(), false);
|
||||
_openToolTipForButton(MaximizeButton(), true);
|
||||
_openToolTipForButton(CloseButton(), false);
|
||||
break;
|
||||
case CaptionButton::Close:
|
||||
VisualStateManager::GoToState(MinimizeButton(), L"Normal", false);
|
||||
VisualStateManager::GoToState(MaximizeButton(), L"Normal", false);
|
||||
VisualStateManager::GoToState(CloseButton(), L"PointerOver", false);
|
||||
if (auto tt{ Controls::ToolTipService::GetToolTip(CloseButton()) })
|
||||
{
|
||||
if (auto tooltip{ tt.try_as<Controls::ToolTip>() })
|
||||
{
|
||||
tooltip.IsOpen(true);
|
||||
}
|
||||
else if (auto s{winrt::unbox_value<winrt::hstring>(tt)}; !s.empty())
|
||||
{
|
||||
s;
|
||||
int a = 0;
|
||||
a++;
|
||||
a;
|
||||
}
|
||||
}
|
||||
_openToolTipForButton(MinimizeButton(), false);
|
||||
_openToolTipForButton(MaximizeButton(), false);
|
||||
_openToolTipForButton(CloseButton(), true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MinMaxCloseControl::PressButton(CaptionButton button)
|
||||
{
|
||||
switch (button)
|
||||
|
@ -168,10 +159,14 @@ namespace winrt::TerminalApp::implementation
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MinMaxCloseControl::ReleaseButtons()
|
||||
{
|
||||
VisualStateManager::GoToState(MinimizeButton(), L"Normal", false);
|
||||
VisualStateManager::GoToState(MaximizeButton(), L"Normal", false);
|
||||
VisualStateManager::GoToState(CloseButton(), L"Normal", false);
|
||||
_openToolTipForButton(MinimizeButton(), false);
|
||||
_openToolTipForButton(MaximizeButton(), false);
|
||||
_openToolTipForButton(CloseButton(), false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,9 +31,6 @@ namespace winrt::TerminalApp::implementation
|
|||
void _CloseClick(winrt::Windows::Foundation::IInspectable const& sender,
|
||||
winrt::Windows::UI::Xaml::RoutedEventArgs const& e);
|
||||
|
||||
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
|
||||
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, MinimizeToolTip, _PropertyChangedHandlers);
|
||||
|
||||
TYPED_EVENT(MinimizeClick, TerminalApp::MinMaxCloseControl, winrt::Windows::UI::Xaml::RoutedEventArgs);
|
||||
TYPED_EVENT(MaximizeClick, TerminalApp::MinMaxCloseControl, winrt::Windows::UI::Xaml::RoutedEventArgs);
|
||||
TYPED_EVENT(CloseClick, TerminalApp::MinMaxCloseControl, winrt::Windows::UI::Xaml::RoutedEventArgs);
|
||||
|
|
|
@ -5,8 +5,7 @@ import "TitlebarControl.idl";
|
|||
|
||||
namespace TerminalApp
|
||||
{
|
||||
[default_interface] runtimeclass MinMaxCloseControl : Windows.UI.Xaml.Controls.StackPanel,
|
||||
Windows.UI.Xaml.Data.INotifyPropertyChanged
|
||||
[default_interface] runtimeclass MinMaxCloseControl : Windows.UI.Xaml.Controls.StackPanel
|
||||
{
|
||||
MinMaxCloseControl();
|
||||
|
||||
|
@ -16,8 +15,6 @@ namespace TerminalApp
|
|||
void PressButton(CaptionButton button);
|
||||
void ReleaseButtons();
|
||||
|
||||
String MinimizeToolTip { get; };
|
||||
|
||||
event Windows.Foundation.TypedEventHandler<MinMaxCloseControl, Windows.UI.Xaml.RoutedEventArgs> MinimizeClick;
|
||||
event Windows.Foundation.TypedEventHandler<MinMaxCloseControl, Windows.UI.Xaml.RoutedEventArgs> MaximizeClick;
|
||||
event Windows.Foundation.TypedEventHandler<MinMaxCloseControl, Windows.UI.Xaml.RoutedEventArgs> CloseClick;
|
||||
|
|
|
@ -423,7 +423,7 @@
|
|||
<data name="WindowMinimizeButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
|
||||
<value>Minimize</value>
|
||||
</data>
|
||||
<data name="WindowMinimizeButtonToolTipText" xml:space="preserve">
|
||||
<data name="WindowMinimizeButtonToolTip.Text" xml:space="preserve">
|
||||
<value>Minimize</value>
|
||||
</data>
|
||||
<data name="AboutDialog.Title" xml:space="preserve">
|
||||
|
|
Loading…
Reference in a new issue