From 9a40ca7b9b3252531847675fcd013a58ccbfc336 Mon Sep 17 00:00:00 2001 From: shikulja Date: Fri, 26 Jul 2024 20:29:27 +0300 Subject: [PATCH] chatcopy: escape to close chatcopy mode --- modules/chatcopy.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/chatcopy.lua b/modules/chatcopy.lua index 98560584a..11da75e0d 100644 --- a/modules/chatcopy.lua +++ b/modules/chatcopy.lua @@ -106,8 +106,20 @@ pfUI:RegisterModule("chatcopy", "vanilla:tbc", function () editbox:SetMultiLine(true) editbox:SetMaxLetters(0) - editbox:SetScript("OnEscapePressed", function () - this:ClearFocus() + editbox:SetScript("OnMouseDown", function() + editbox.hasFocus = true + end) + + editbox:SetScript("OnEscapePressed", function() + if editbox.hasFocus then + editbox:HighlightText(0, 0) + editbox:ClearFocus() + editbox.hasFocus = false + else + editbox:GetParent():Hide() + pfChatCopyButton.icon:SetTexture("Interface\\Buttons\\UI-GuildButton-PublicNote-Disabled") + pfChatCopyButton.state = false + end end) scroll:SetScrollChild(editbox)