Cleanup from the experimentation phase
This commit is contained in:
parent
242de14722
commit
d6d708796a
|
@ -23,26 +23,6 @@ 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)
|
||||
|
@ -59,7 +39,19 @@ namespace winrt::TerminalApp::implementation
|
|||
return _control;
|
||||
}
|
||||
|
||||
void AdminWarningPlaceholder::FocusOnLaunch() {
|
||||
// Method Description:
|
||||
// - Move the focus to the cancel button by default. This has the LOAD
|
||||
// BEARING side effect of also triggering Narrator to read out the
|
||||
// contents of the dialog. It's unclear why doing this works, but it does.
|
||||
// - Using a LayoutUpdated event to trigger the focus change when we're
|
||||
// added to the UI tree did not seem to work.
|
||||
// - Whoever is adding us to the UI tree is responsible for calling this!
|
||||
// Arguments:
|
||||
// - <none>
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void AdminWarningPlaceholder::FocusOnLaunch()
|
||||
{
|
||||
CancelButton().Focus(FocusState::Programmatic);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -309,26 +309,13 @@ namespace winrt::TerminalApp::implementation
|
|||
|
||||
if (doAdminWarning)
|
||||
{
|
||||
// We know this is safe - we literally just added the
|
||||
// AdminWarningPlaceholder as the controlToAdd like 20 lines up.
|
||||
//
|
||||
// Focus the warning here. The LayoutUpdated within the dialog
|
||||
// itself isn't good enough. That, for some reason, fires _before_
|
||||
// the dialog is in the UI tree, which is useless for us.
|
||||
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 */
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
//});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1840,7 +1840,8 @@ namespace winrt::TerminalApp::implementation
|
|||
WUX::Controls::UserControl controlToAdd{ newControl };
|
||||
|
||||
const auto& cmdline{ controlSettings.DefaultSettings().Commandline() };
|
||||
if (_shouldPromptForCommandline(cmdline))
|
||||
const auto doAdminWarning{ _shouldPromptForCommandline(cmdline) };
|
||||
if (doAdminWarning)
|
||||
{
|
||||
auto warningControl{ winrt::make_self<implementation::AdminWarningPlaceholder>(newControl, cmdline) };
|
||||
warningControl->PrimaryButtonClicked({ get_weak(), &TerminalPage::_adminWarningPrimaryClicked });
|
||||
|
@ -1865,6 +1866,17 @@ namespace winrt::TerminalApp::implementation
|
|||
activeControl.Focus(FocusState::Programmatic);
|
||||
}
|
||||
}
|
||||
|
||||
if (doAdminWarning)
|
||||
{
|
||||
// We know this is safe - we literally just added the
|
||||
// AdminWarningPlaceholder as the controlToAdd like 20 lines up.
|
||||
//
|
||||
// Focus the warning here. The LayoutUpdated within the dialog
|
||||
// itself isn't good enough. That, for some reason, fires _before_
|
||||
// the dialog is in the UI tree, which is useless for us.
|
||||
controlToAdd.try_as<implementation::AdminWarningPlaceholder>()->FocusOnLaunch();
|
||||
}
|
||||
}
|
||||
CATCH_LOG();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue