Index: Editbox.lua
===================================================================
--- Editbox.lua	(revision 15310)
+++ Editbox.lua	(working copy)
@@ -26,6 +26,8 @@
     ["Lock editbox position is undocked"] = true,
     ["Arrowkeys"] = true,
     ["Toggle using arrowkeys in editbox without the alt key"] = true,
+    ["Sticky"] = true,
+    ["Toggle text clearing when editbox is closed"] = true,
     ["Toggle"] = true,
     ["Toggle the module on and off"] = true,
 } end)
@@ -58,6 +60,7 @@
         width = 400,
         undocked = {point = "CENTER", relativeTo="UIParent", relativePoint = "CENTER", xoff = 0, yoff = 0},
         locked = false,
+        sticky = false,
         arrowkeys = true
     })
     Prat.Options.args.editbox = {
@@ -129,13 +132,24 @@
                 end,
                 order = 199
             },
+            sticky = {
+                name = L["Sticky"],
+                desc = L["Toggle text clearing when editbox is closed"],
+                type = "toggle",
+                get = function() return self.db.profile.sticky end,
+                set = function(v)
+                    self.db.profile.sticky = v
+                    self:Sticky(v)
+                end,
+                order = 200
+            },
             toggle = {
                 name = L["Toggle"],
                 desc = L["Toggle the module on and off"],
                 type = "toggle",
                 get = function() return self.db.profile.on end,
                 set = function() self.db.profile.on = Prat:ToggleModuleActive("editbox") end,
-                order = 200
+                order = 201
             }
         }
     }
@@ -145,12 +159,14 @@
     self:Position(self.db.profile.position)
     self:Alpha(self.db.profile.alpha)
     self:ArrowKeys(self.db.profile.arrowkeys)
+    self:Sticky(self.db.profile.sticky)
 end
 
 function Prat_Editbox:OnDisable()
     self:Position("BOTTOM")
     self:Alpha(1)
     self:ArrowKeys(false)
+    self:Sticky(false)
 end
 
 function Prat_Editbox:Alpha(value)
@@ -196,3 +212,65 @@
         eb:SetWidth(self.db.profile.width)
     end
 end
+
+function Prat_Editbox:Sticky(enabled)
+    if not enabled then
+         DEFAULT_CHAT_FRAME.editBox:SetScript("OnEscapePressed", 
+            function()
+                ChatEdit_OnEscapePressed(this)
+            end
+        )
+	DEFAULT_CHAT_FRAME.editBox:SetScript("OnEnterPressed",
+		function() ChatEdit_OnEnterPressed() end
+	)
+        self:Unhook("ChatFrame_OpenChat")
+        self:Unhook("ChatFrame_ReplyTell")
+        self:Unhook("ChatFrame_ReplyTell2")
+    else
+        DEFAULT_CHAT_FRAME.editBox:SetScript("OnEscapePressed", 
+            function()
+                this.oldText = this:GetText()
+                this.oldChatType = this.chatType
+                ChatEdit_OnEscapePressed(this)
+            end
+        )
+        DEFAULT_CHAT_FRAME.editBox:SetScript("OnEnterPressed",
+            function()
+                this.oldText = nil
+                this.oldChatType = nil
+                ChatEdit_OnEnterPressed()
+            end
+        )
+        self:Hook("ChatFrame_OpenChat",
+            function(text, chatFrame)
+                local editBox =  DEFAULT_CHAT_FRAME.editBox
+                if (not chatFrame or chatFrame == DEFAULT_CHAT_FRAME) and text == "" and 
+                        editBox.oldText and editBox.oldText ~= "" then
+                    editBox:SetText(editBox.oldText)
+                    editBox.chatType = editBox.oldChatType
+                    editBox:Show()
+                else
+                    self.hooks["ChatFrame_OpenChat"](text, chatFrame)
+                end
+            end
+        )
+        self:Hook("ChatFrame_ReplyTell",
+            function(chatFrame)
+                if ( not chatFrame ) then
+		            chatFrame = DEFAULT_CHAT_FRAME;
+                end
+                chatFrame.editBox.oldText = nil
+                self.hooks["ChatFrame_ReplyTell"](chatFrame)
+            end
+        )
+        self:Hook("ChatFrame_ReplyTell2",
+            function(chatFrame)
+                if ( not chatFrame ) then
+		            chatFrame = DEFAULT_CHAT_FRAME;
+                end
+                chatFrame.editBox.oldText = nil
+                self.hooks["ChatFrame_ReplyTell2"](chatFrame)
+            end
+        ) 
+    end
+end
