diff --git a/Import/GacUI.cpp b/Import/GacUI.cpp index 53562196..ff57eeb0 100644 --- a/Import/GacUI.cpp +++ b/Import/GacUI.cpp @@ -26187,17 +26187,22 @@ GuiToolstripCommand return nullptr; } + void GuiToolstripCommand::RemoveShortcut() + { + if (shortcutKeyItem) + { + shortcutKeyItem->Executed.Detach(shortcutKeyItemExecutedHandler); + shortcutKeyItem->GetManager()->DestroyShortcut(shortcutKeyItem); + } + shortcutKeyItem = nullptr; + shortcutKeyItemExecutedHandler = nullptr; + } + void GuiToolstripCommand::ReplaceShortcut(compositions::IGuiShortcutKeyItem* value) { if (shortcutKeyItem != value) { - if (shortcutKeyItem) - { - shortcutKeyItem->Executed.Detach(shortcutKeyItemExecutedHandler); - shortcutKeyItem->GetManager()->DestroyShortcut(shortcutKeyItem); - } - shortcutKeyItem = nullptr; - shortcutKeyItemExecutedHandler = nullptr; + RemoveShortcut(); if (value) { shortcutKeyItem = value; @@ -26258,10 +26263,8 @@ GuiToolstripCommand GuiToolstripCommand::~GuiToolstripCommand() { - if (shortcutBuilder && shortcutKeyItem) - { - ReplaceShortcut(nullptr); - } + RemoveShortcut(); + shortcutBuilder = nullptr; } void GuiToolstripCommand::Attach(GuiInstanceRootObject* rootObject) diff --git a/Import/GacUI.h b/Import/GacUI.h index ed677c06..96c1670d 100644 --- a/Import/GacUI.h +++ b/Import/GacUI.h @@ -10427,6 +10427,7 @@ namespace vl void InvokeDescriptionChanged(); compositions::IGuiShortcutKeyManager* GetShortcutManagerFromBuilder(Ptr builder); + void RemoveShortcut(); void ReplaceShortcut(compositions::IGuiShortcutKeyItem* value); void BuildShortcut(const WString& builderText); void UpdateShortcutOwner(); diff --git a/Tutorial/GacUI_Controls/GlobalHotKey/UI/Resource.xml b/Tutorial/GacUI_Controls/GlobalHotKey/UI/Resource.xml index b0be3860..6ac2de46 100644 --- a/Tutorial/GacUI_Controls/GlobalHotKey/UI/Resource.xml +++ b/Tutorial/GacUI_Controls/GlobalHotKey/UI/Resource.xml @@ -17,7 +17,7 @@ { GuiApplication::GetApplication().InvokeInMainThread(self, func():void { - dialog.ShowDialog();-eval + dialog.ShowDialog(); }); } ]]> @@ -31,7 +31,7 @@ - +
<_>composeType:MinSize <_>composeType:Percentage percentage:1.0 @@ -53,9 +53,9 @@ - +
diff --git a/Tutorial/GacUI_Controls/GlobalHotKey/UI/Source/DemoPartialClasses.cpp b/Tutorial/GacUI_Controls/GlobalHotKey/UI/Source/DemoPartialClasses.cpp index 92ec48a9..7b8eacda 100644 --- a/Tutorial/GacUI_Controls/GlobalHotKey/UI/Source/DemoPartialClasses.cpp +++ b/Tutorial/GacUI_Controls/GlobalHotKey/UI/Source/DemoPartialClasses.cpp @@ -164,7 +164,7 @@ namespace demo ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); } { - ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetBorderVisible(true); + ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetBorderVisible(false); } { ::vl::__vwsn::This(this->__vwsn_precompile_3)->SetCellPadding(static_cast<::vl::vint>(5)); @@ -219,7 +219,7 @@ namespace demo } (this->__vwsn_precompile_11 = new ::vl::presentation::compositions::GuiCellComposition()); { - ::vl::__vwsn::This(this->__vwsn_precompile_11)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); + ::vl::__vwsn::This(this->__vwsn_precompile_11)->SetSite(static_cast<::vl::vint>(1), static_cast<::vl::vint>(0), static_cast<::vl::vint>(1), static_cast<::vl::vint>(1)); } { (this->__vwsn_precompile_12 = new ::vl::presentation::controls::GuiLabel(::vl::presentation::theme::ThemeName::Label)); @@ -229,7 +229,7 @@ namespace demo } (this->__vwsn_precompile_13 = ::vl::__vwsn::This(this->__vwsn_precompile_12)->GetBoundsComposition()); { - ::vl::__vwsn::This(this->__vwsn_precompile_13)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(0); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(0); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); + ::vl::__vwsn::This(this->__vwsn_precompile_13)->SetAlignmentToParent([&](){ ::vl::presentation::Margin __vwsn_temp__; __vwsn_temp__.left = static_cast<::vl::vint>(5); __vwsn_temp__.top = static_cast<::vl::vint>(0); __vwsn_temp__.right = static_cast<::vl::vint>(5); __vwsn_temp__.bottom = static_cast<::vl::vint>(0); return __vwsn_temp__; }()); } { ::vl::__vwsn::This(this->__vwsn_precompile_12)->SetText(::vl::WString::Unmanaged(L"Right click to show the menu"));