Incredible that this works at all
This commit is contained in:
parent
69f1068050
commit
242de14722
|
@ -7,6 +7,7 @@
|
|||
#include "AdminWarningPlaceholder.h"
|
||||
#include "AdminWarningPlaceholder.g.cpp"
|
||||
using namespace winrt::Windows::UI::Xaml;
|
||||
using namespace winrt::Windows::UI::Xaml::Automation::Peers;
|
||||
|
||||
namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
|
@ -22,6 +23,26 @@ namespace winrt::TerminalApp::implementation
|
|||
{
|
||||
RootGrid().Background(termControl.BackgroundBrush());
|
||||
}
|
||||
|
||||
CancelButton().LayoutUpdated([this](auto&&, auto&&) { CancelButton().Focus(FocusState::Programmatic); });
|
||||
//LayoutUpdated([this](auto&&, auto&&) {
|
||||
// if (auto automationPeer{ FrameworkElementAutomationPeer::FromElement(ApproveCommandlineWarningTitle()) })
|
||||
// {
|
||||
// //auto foo{ automationPeer.try_as<FrameworkElementAutomationPeer>() };
|
||||
// //foo.RaiseStructureChangedEvent(Automation::Peers::AutomationStructureChangeType::ChildrenBulkAdded,
|
||||
// // automationPeer);
|
||||
|
||||
// //automationPeer.RaiseNotificationEvent(
|
||||
// // AutomationNotificationKind::ActionCompleted,
|
||||
// // AutomationNotificationProcessing::CurrentThenMostRecent,
|
||||
// // L"Foo",
|
||||
// // L"ApproveCommandlineWarningTitle" /* unique name for this notification category */
|
||||
// //);
|
||||
|
||||
// automationPeer.RaiseAutomationEvent(AutomationEvents::StructureChanged);
|
||||
// }
|
||||
|
||||
//});
|
||||
}
|
||||
void AdminWarningPlaceholder::_primaryButtonClick(winrt::Windows::Foundation::IInspectable const& /*sender*/,
|
||||
RoutedEventArgs const& e)
|
||||
|
@ -37,4 +58,8 @@ namespace winrt::TerminalApp::implementation
|
|||
{
|
||||
return _control;
|
||||
}
|
||||
|
||||
void AdminWarningPlaceholder::FocusOnLaunch() {
|
||||
CancelButton().Focus(FocusState::Programmatic);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace winrt::TerminalApp::implementation
|
|||
struct AdminWarningPlaceholder : AdminWarningPlaceholderT<AdminWarningPlaceholder>
|
||||
{
|
||||
AdminWarningPlaceholder(const winrt::Microsoft::Terminal::Control::TermControl& control, const winrt::hstring& cmdline);
|
||||
|
||||
void FocusOnLaunch();
|
||||
winrt::Windows::UI::Xaml::Controls::UserControl Control();
|
||||
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
|
||||
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Commandline, _PropertyChangedHandlers);
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
xmlns:local="using:TerminalApp"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
|
||||
AutomationProperties.AccessibilityView="Content"
|
||||
AutomationProperties.IsDialog="True"
|
||||
AutomationProperties.Name="Baz"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<!--
|
||||
|
@ -27,29 +30,37 @@
|
|||
VerticalAlignment="Center">
|
||||
<Border Margin="8,8,8,8"
|
||||
Padding="16,8,16,8"
|
||||
AllowFocusOnInteraction="True"
|
||||
AutomationProperties.AccessibilityView="Raw"
|
||||
AutomationProperties.IsDialog="True"
|
||||
AutomationProperties.Name="TODO bind me like command palette"
|
||||
Background="{ThemeResource SystemControlBackgroundAltHighBrush}"
|
||||
BorderBrush="{ThemeResource SystemAccentColor}"
|
||||
BorderThickness="2,2,2,2"
|
||||
CornerRadius="{ThemeResource OverlayCornerRadius}">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock x:Uid="ApproveCommandlineWarningTitle"
|
||||
<TextBlock x:Name="ApproveCommandlineWarningTitle"
|
||||
x:Uid="ApproveCommandlineWarningTitle"
|
||||
Padding="0,0,0,16"
|
||||
HorizontalAlignment="Left"
|
||||
FontSize="20"
|
||||
FontWeight="Normal"
|
||||
TextWrapping="WrapWholeWords" />
|
||||
|
||||
<TextBlock x:Uid="ApproveCommandlineWarningPrefixTextBlock"
|
||||
<TextBlock x:Name="PrefixTextBlock"
|
||||
x:Uid="ApproveCommandlineWarningPrefixTextBlock"
|
||||
HorizontalAlignment="Left"
|
||||
TextWrapping="WrapWholeWords" />
|
||||
|
||||
<TextBlock Margin="0,16,0,16"
|
||||
<TextBlock x:Name="CommandlineText"
|
||||
Margin="0,16,0,16"
|
||||
HorizontalAlignment="Left"
|
||||
FontFamily="Cascadia Mono"
|
||||
Text="{x:Bind Commandline, Mode=OneWay}"
|
||||
TextWrapping="WrapWholeWords" />
|
||||
|
||||
<TextBlock x:Uid="ApproveCommandlineWarningSuffixTextBlock"
|
||||
<TextBlock x:Name="SuffixTextBlock"
|
||||
x:Uid="ApproveCommandlineWarningSuffixTextBlock"
|
||||
HorizontalAlignment="Left"
|
||||
TextWrapping="WrapWholeWords" />
|
||||
<Grid Margin="0,8,0,8"
|
||||
|
@ -65,12 +76,14 @@
|
|||
Margin="0,0,8,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
Click="_primaryButtonClick"
|
||||
IsTabStop="True"
|
||||
Style="{StaticResource AccentButtonStyle}" />
|
||||
<Button x:Name="CancelButton"
|
||||
x:Uid="ApproveCommandlineWarning_CancelButton"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Stretch"
|
||||
Click="_cancelButtonClick" />
|
||||
Click="_cancelButtonClick"
|
||||
IsTabStop="True" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
|
|
@ -306,6 +306,30 @@ namespace winrt::TerminalApp::implementation
|
|||
// Split (auto) with the debug tap.
|
||||
newTabImpl->SplitPane(SplitDirection::Automatic, 0.5f, profile, newControl);
|
||||
}
|
||||
|
||||
if (doAdminWarning)
|
||||
{
|
||||
controlToAdd.try_as<implementation::AdminWarningPlaceholder>()->FocusOnLaunch();
|
||||
//Root().Dispatcher().TryRunAsync(CoreDispatcherPriority::Low, [weakThis = get_weak()]() {
|
||||
// if (auto self{ weakThis.get() })
|
||||
// {
|
||||
// if (auto automationPeer{ WUX::Automation::Peers::FrameworkElementAutomationPeer::FromElement(self->Root()) })
|
||||
// {
|
||||
// auto foo{ automationPeer.try_as<WUX::Automation::Peers::FrameworkElementAutomationPeer>() };
|
||||
// foo.RaiseStructureChangedEvent(Automation::Peers::AutomationStructureChangeType::ChildrenBulkAdded,
|
||||
// automationPeer);
|
||||
|
||||
// automationPeer.RaiseNotificationEvent(
|
||||
// WUX::Automation::Peers::AutomationNotificationKind::ActionCompleted,
|
||||
// WUX::Automation::Peers::AutomationNotificationProcessing::CurrentThenMostRecent,
|
||||
// L"Bar",
|
||||
// L"ApproveCommandlineWarningTitle2todo" /* unique name for this notification category */
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
//});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
|
Loading…
Reference in a new issue