changeset 49:7d5934415ad0 r49-release

- framework update.
author Tercio
date Wed, 05 Jul 2017 15:20:21 -0300
parents a671a2cf52ee
children e33a1e89084c
files Libs/DF/button.lua Libs/DF/fw.lua Libs/DF/panel.lua Libs/DF/pictureedit.lua Libs/DF/textentry.lua
diffstat 5 files changed, 272 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/Libs/DF/button.lua	Mon May 08 14:58:23 2017 -0300
+++ b/Libs/DF/button.lua	Wed Jul 05 15:20:21 2017 -0300
@@ -394,7 +394,7 @@
 	end
 
 -- icon
-	function ButtonMetaFunctions:SetIcon (texture, width, height, layout, texcoord, overlay, textdistance, leftpadding, textheight)
+	function ButtonMetaFunctions:SetIcon (texture, width, height, layout, texcoord, overlay, textdistance, leftpadding, textheight, short_method)
 		if (not self.icon) then
 			self.icon = self:CreateTexture (nil, "artwork")
 			self.icon:SetSize (self.height*0.8, self.height*0.8)
@@ -427,9 +427,13 @@
 		local iconw = self.icon:GetWidth()
 		local text_width = self.button.text:GetStringWidth()
 		if (text_width > w-15-iconw) then
-			if (not short_method) then
+
+			if (short_method == false) then
+			
+			elseif (not short_method) then
 				local new_width = text_width+15+iconw
 				self.button:SetWidth (new_width)
+				
 			elseif (short_method == 1) then
 				local loop = true
 				local textsize = 11
@@ -443,6 +447,7 @@
 						textsize = textsize - 1
 					end
 				end
+				
 			end
 		end
 		
@@ -1015,6 +1020,9 @@
 					textsize = textsize - 1
 				end
 			end
+			
+		elseif (short_method == 2) then
+			
 		end
 	end
 	
--- a/Libs/DF/fw.lua	Mon May 08 14:58:23 2017 -0300
+++ b/Libs/DF/fw.lua	Wed Jul 05 15:20:21 2017 -0300
@@ -1,5 +1,5 @@
 
-local dversion = 50
+local dversion = 54
 local major, minor = "DetailsFramework-1.0", dversion
 local DF, oldminor = LibStub:NewLibrary (major, minor)
 
@@ -304,10 +304,18 @@
 	return fontface
 end
 
+local ValidOutlines = {
+	["NONE"] = true,
+	["MONOCHROME"] = true,
+	["OUTLINE"] = true,
+	["THICKOUTLINE"] = true,
+}
 function DF:SetFontOutline (fontString, outline)
 	local fonte, size = fontString:GetFont()
 	if (outline) then
-		if (_type (outline) == "boolean" and outline) then
+		if (ValidOutlines [outline]) then
+			outline = outline
+		elseif (_type (outline) == "boolean" and outline) then
 			outline = "OUTLINE"
 		elseif (outline == 1) then
 			outline = "OUTLINE"
@@ -650,7 +658,7 @@
 				
 			elseif (widget_table.type == "execute" or widget_table.type == "button") then
 			
-				local button = DF:NewButton (parent, nil, "$parentWidget" .. index, nil, 120, 18, widget_table.func, widget_table.param1, widget_table.param2, nil, widget_table.name, nil, button_template)
+				local button = DF:NewButton (parent, nil, "$parentWidget" .. index, nil, 120, 18, widget_table.func, widget_table.param1, widget_table.param2, nil, widget_table.name, nil, button_template, text_template)
 				if (not button_template) then
 					button:InstallCustomTexture()
 				end
@@ -667,6 +675,28 @@
 				tinsert (parent.widget_list, button)
 				widget_created = button
 				
+				
+			elseif (widget_table.type == "textentry") then
+				local textentry = DF:CreateTextEntry (parent, widget_table.func, 120, 18, nil, "$parentWidget" .. index, nil, button_template)
+				textentry.tooltip = widget_table.desc
+				textentry.text = widget_table.get()
+				textentry._get = widget_table.get
+				textentry.widget_type = "textentry"
+				textentry:SetHook ("OnEnterPressed", widget_table.set)
+				textentry:SetHook ("OnEditFocusLost", widget_table.set)
+
+				local label = DF:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name .. (use_two_points and ": " or ""), "GameFontNormal", widget_table.text_template or text_template or 12)
+				textentry:SetPoint ("left", label, "right", 2)
+				label:SetPoint (cur_x, cur_y)
+
+				local size = label.widget:GetStringWidth() + 60 + 4
+				if (size > max_x) then
+					max_x = size
+				end
+				
+				tinsert (parent.widget_list, textentry)
+				widget_created = textentry
+				
 			end
 			
 			if (widget_table.nocombat) then
@@ -840,6 +870,8 @@
 					widget:Select (widget._get())
 				elseif (widget.widget_type == "toggle" or widget.widget_type == "range") then
 					widget:SetValue (widget._get())
+				elseif (widget.widget_type == "textentry") then
+					widget:SetText (widget._get())
 				elseif (widget.widget_type == "color") then
 					local default_value, g, b, a = widget._get()
 					if (type (default_value) == "table") then
--- a/Libs/DF/panel.lua	Mon May 08 14:58:23 2017 -0300
+++ b/Libs/DF/panel.lua	Wed Jul 05 15:20:21 2017 -0300
@@ -517,9 +517,15 @@
 
 local button_on_enter = function (self)
 	self.MyObject._icon:SetBlendMode ("ADD")
+	if (self.MyObject.onenter_func) then
+		pcall (self.MyObject.onenter_func, self.MyObject)
+	end
 end
 local button_on_leave = function (self)
 	self.MyObject._icon:SetBlendMode ("BLEND")
+	if (self.MyObject.onleave_func) then
+		pcall (self.MyObject.onleave_func, self.MyObject)
+	end
 end
 
 local add_row = function (self, t, need_update)
@@ -537,6 +543,9 @@
 	
 	thisrow.hidden = t.hidden or false
 	
+	thisrow.onenter = t.onenter
+	thisrow.onleave = t.onleave
+	
 	local text = DF:NewLabel (thisrow, nil, self._name .. "$parentLabel" .. index, "text")
 	text:SetPoint ("left", thisrow, "left", 2, 0)
 	text:SetText (t.name)
@@ -618,6 +627,16 @@
 						entry:SetWidth (row.width)
 					end
 					entry.func = row.func
+					
+					entry.onenter_func = nil
+					entry.onleave_func = nil
+					
+					if (row.onenter) then
+						entry.onenter_func = row.onenter
+					end
+					if (row.onleave) then
+						entry.onleave_func = row.onleave
+					end
 				end
 			elseif (type == "button") then
 				for i = 1, #self.scrollframe.lines do
@@ -652,7 +671,17 @@
 					if (row.name and not row.notext) then
 						button._text:SetPoint ("left", button._icon, "right", 2, 0)
 						button._text.text = row.name
-					end					
+					end
+					
+					button.onenter_func = nil
+					button.onleave_func = nil
+					
+					if (row.onenter) then
+						button.onenter_func = row.onenter
+					end
+					if (row.onleave) then
+						button.onleave_func = row.onleave
+					end
 					
 				end
 			elseif (type == "icon") then
@@ -667,6 +696,19 @@
 					icon:SetPoint ("left", line, "left", self._anchors [#self._anchors] + ( ((row.width or 22) - 22) / 2), 0)
 					icon.func = row.func
 				end
+				
+			elseif (type == "texture") then
+				for i = 1, #self.scrollframe.lines do
+					local line = self.scrollframe.lines [i]
+					local texture = tremove (line.texture_available)
+					if (not texture) then
+						self:CreateRowTexture (line)
+						texture = tremove (line.texture_available)
+					end
+					tinsert (line.texture_inuse, texture)
+					texture:SetPoint ("left", line, "left", self._anchors [#self._anchors] + ( ((row.width or 22) - 22) / 2), 0)
+				end
+				
 			end
 			
 			sindex = sindex + 1
@@ -687,6 +729,7 @@
 end
 
 local update_rows = function (self, updated_rows)
+
 	for i = 1, #updated_rows do
 		local t = updated_rows [i]
 		local raw = self._raw_rows [i]
@@ -705,6 +748,11 @@
 			widget.textalign = t.textalign
 			widget.hidden = t.hidden or false
 			
+			--
+			widget.onenter = t.onenter
+			widget.onleave = t.onleave
+			--
+			
 			widget.text:SetText (t.name)
 			DF:SetFontSize (widget.text, raw.textsize or 10)
 			widget.text:SetJustifyH (raw.textalign or "left")
@@ -747,6 +795,13 @@
 		for i = 1, #row.icon_available do
 			row.icon_available[i]:Hide()
 		end
+		
+		for i = #row.texture_inuse, 1, -1 do
+			tinsert (row.texture_available, tremove (row.texture_inuse, i))
+		end
+		for i = 1, #row.texture_available do
+			row.texture_available[i]:Hide()
+		end
 	end
 	
 	self.current_header = updated_rows
@@ -771,7 +826,18 @@
 		editbox:ClearFocus()
 		editbox.func (editbox.index, editbox.text)
 		return true
-	end) 
+	end)
+	
+	editbox:SetHook ("OnEnter", function()
+		if (editbox.onenter_func) then
+			pcall (editbox.onenter_func, editbox)
+		end
+	end)
+	editbox:SetHook ("OnLeave", function()
+		if (editbox.onleave_func) then
+			pcall (editbox.onleave_func, editbox)
+		end
+	end)
 	
 	editbox:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", edgeSize = 1})
 	editbox:SetBackdropColor (1, 1, 1, 0.1)
@@ -784,8 +850,6 @@
 local create_panel_button = function (self, row)
 	row.button_total = row.button_total + 1
 	local button = DF:NewButton (row, nil, "$parentButton" .. row.button_total, "button" .. row.button_total, 120, 20)
-	--, nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE")
-	--button:InstallCustomTexture()
 
 	--> create icon and the text
 	local icon = DF:NewImage (button, nil, 20, 20)
@@ -826,6 +890,12 @@
 	tinsert (row.icon_available, iconbutton)
 end
 
+local create_panel_texture = function (self, row)
+	row.texture_total = row.texture_total + 1
+	local texture = DF:NewImage (row, nil, 20, 20, "artwork", nil, "_icon" .. row.texture_total, "$parentIcon" .. row.texture_total)
+	tinsert (row.texture_available, texture)
+end
+
 local set_fill_function = function (self, func)
 	self._fillfunc = func
 end
@@ -872,6 +942,7 @@
 	panel.CreateRowEntry = create_panel_entry
 	panel.CreateRowButton = create_panel_button
 	panel.CreateRowIcon = create_panel_icon
+	panel.CreateRowTexture = create_panel_texture
 	panel.SetFillFunction = set_fill_function
 	panel.SetTotalFunction = set_total_function
 	panel.DropHeader = drop_header_function
@@ -906,10 +977,10 @@
 				local real_index = index + offset
 				local results = panel._fillfunc (real_index, panel)
 				
-				if (results [1]) then
+				if (results and results [1]) then
 					row:Show()
 
-					local text, entry, button, icon = 1, 1, 1, 1
+					local text, entry, button, icon, texture = 1, 1, 1, 1, 1
 					
 					for index, t in ipairs (panel.rows) do
 						if (not t.hidden) then
@@ -919,25 +990,30 @@
 								fontstring:SetText (results [index])
 								fontstring.index = real_index
 								fontstring:Show()
-								
-								if (true) then
-									--print (t.hello)
-								end
 
 							elseif (t.type == "entry") then
 								local entrywidget = row.entry_inuse [entry]
 								entry = entry + 1
-								entrywidget:SetText (results [index])
 								entrywidget.index = real_index
+								
+								if (type (results [index]) == "table") then
+									entrywidget:SetText (results [index].text)
+									entrywidget.id = results [index].id
+									entrywidget.data1 = results [index].data1
+									entrywidget.data2 = results [index].data2
+								else
+									entrywidget:SetText (results [index])
+								end
+								
+								entrywidget:SetCursorPosition(0)
+								
 								entrywidget:Show()
 								
 							elseif (t.type == "button") then
 								local buttonwidget = row.button_inuse [button]
 								button = button + 1
 								buttonwidget.index = real_index
-							
 
-							
 								if (type (results [index]) == "table") then
 									if (results [index].text) then
 										buttonwidget:SetText (results [index].text)
@@ -960,6 +1036,11 @@
 										end
 										buttonwidget:SetClickFunction (func)
 									end
+									
+									buttonwidget.id = results [index].id
+									buttonwidget.data1 = results [index].data1
+									buttonwidget.data2 = results [index].data2
+									
 								else
 									local func = function()
 										t.func (real_index, index)
@@ -987,6 +1068,22 @@
 								end
 								
 								iconwidget:Show()
+								
+							elseif (t.type == "texture") then
+								local texturewidget = row.texture_inuse [texture]
+								texture = texture + 1
+								
+								texturewidget.line = index
+								texturewidget.index = real_index
+
+								if (type (results [index]) == "string") then
+									local result = results [index]:gsub (".-%\\", "")
+									texturewidget.texture = results [index]
+								else
+									texturewidget:SetTexture (results [index])
+								end
+								
+								texturewidget:Show()
 							end
 						end
 					end
@@ -1010,6 +1107,7 @@
 		local line_height = options.rowheight
 		refresh_fillbox (panel.scrollframe)
 		FauxScrollFrame_Update (panel.scrollframe, filled_lines, scroll_total_lines, line_height)
+		panel.scrollframe:Show()
 	end
 	
 	local scrollframe = CreateFrame ("scrollframe", name .. "Scroll", panel.widget, "FauxScrollFrameTemplate")
@@ -1059,6 +1157,10 @@
 			row.icon_available = {}
 			row.icon_inuse = {}
 			row.icon_total = 0
+
+			row.texture_available = {}
+			row.texture_inuse = {}
+			row.texture_total = 0
 		end
 	end
 	panel:UpdateRowAmount()
@@ -1526,7 +1628,7 @@
 
 local no_options = {}
 function DF:CreateSimplePanel (parent, w, h, title, name, panel_options, db)
-
+	
 	if (db and name and not db [name]) then
 		db [name] = {scale = 1}
 	end
@@ -1540,7 +1642,7 @@
 	end
 	
 	panel_options = panel_options or no_options
-
+	
 	local f = CreateFrame ("frame", name, UIParent)
 	f:SetSize (w or 400, h or 250)
 	f:SetPoint ("center", UIParent, "center", 0, 0)
--- a/Libs/DF/pictureedit.lua	Mon May 08 14:58:23 2017 -0300
+++ b/Libs/DF/pictureedit.lua	Wed Jul 05 15:20:21 2017 -0300
@@ -12,7 +12,7 @@
 	window:SetMovable (true)
 	tinsert (UISpecialFrames, "DetailsFrameworkImageEdit")
 	window:SetFrameStrata ("TOOLTIP")
-	window:SetMaxResize (266, 226)
+	window:SetMaxResize (650, 500)
 	
 	window.hooks = {}
 	
@@ -20,13 +20,13 @@
 	background:SetAllPoints()
 	background:SetTexture (0, 0, 0, .8)
 	
-	local edit_texture = DF:NewImage (window, nil, 300, 250, "artwork", nil, nil, "$parentImage")
+	local edit_texture = DF:NewImage (window, nil, 650, 500, "artwork", nil, nil, "$parentImage")
 	edit_texture:SetAllPoints()
 	
 	local background_frame = CreateFrame ("frame", "DetailsFrameworkImageEditBackground", DetailsFrameworkImageEdit)
 	background_frame:SetPoint ("topleft", DetailsFrameworkImageEdit, "topleft", -10, 12)
 	background_frame:SetFrameStrata ("DIALOG")
-	background_frame:SetSize (400, 252)
+	background_frame:SetSize (800, 540)
 	
 	background_frame:SetResizable (true)
 	background_frame:SetMovable (true)
@@ -50,7 +50,7 @@
 		local topCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageTopCoord")
 		topCoordTexture:SetPoint ("topleft", window, "topleft")
 		topCoordTexture:SetPoint ("topright", window, "topright")
-		topCoordTexture.color = "red"
+		topCoordTexture:SetColorTexture (1, 0, 0)
 		topCoordTexture.height = 1
 		topCoordTexture.alpha = .2
 		
@@ -63,9 +63,9 @@
 		topSlider:SetHook ("OnLeave", function() return true end)
 
 		local topSliderThumpTexture = topSlider:CreateTexture (nil, "overlay")
-		topSliderThumpTexture:SetTexture (1, 1, 1)
+		topSliderThumpTexture:SetColorTexture (1, 1, 1)
 		topSliderThumpTexture:SetWidth (512)
-		topSliderThumpTexture:SetHeight (3)
+		topSliderThumpTexture:SetHeight (1)
 		topSlider:SetThumbTexture (topSliderThumpTexture)
 
 		topSlider:SetHook ("OnValueChange", function (_, _, value)
@@ -82,7 +82,7 @@
 		local bottomCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageBottomCoord")
 		bottomCoordTexture:SetPoint ("bottomleft", window, "bottomleft", 0, 0)
 		bottomCoordTexture:SetPoint ("bottomright", window, "bottomright", 0, 0)
-		bottomCoordTexture.color = "red"
+		bottomCoordTexture:SetColorTexture (1, 0, 0)
 		bottomCoordTexture.height = 1
 		bottomCoordTexture.alpha = .2
 
@@ -95,9 +95,9 @@
 		bottomSlider:SetHook ("OnLeave", function() return true end)
 
 		local bottomSliderThumpTexture = bottomSlider:CreateTexture (nil, "overlay")
-		bottomSliderThumpTexture:SetTexture (1, 1, 1)
+		bottomSliderThumpTexture:SetColorTexture (1, 1, 1)
 		bottomSliderThumpTexture:SetWidth (512)
-		bottomSliderThumpTexture:SetHeight (3)
+		bottomSliderThumpTexture:SetHeight (1)
 		bottomSlider:SetThumbTexture (bottomSliderThumpTexture)
 
 		bottomSlider:SetHook ("OnValueChange", function (_, _, value)
@@ -115,7 +115,7 @@
 		local leftCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageLeftCoord")
 		leftCoordTexture:SetPoint ("topleft", window, "topleft", 0, 0)
 		leftCoordTexture:SetPoint ("bottomleft", window, "bottomleft", 0, 0)
-		leftCoordTexture.color = "red"
+		leftCoordTexture:SetColorTexture (1, 0, 0)
 		leftCoordTexture.width = 1
 		leftCoordTexture.alpha = .2
 		
@@ -127,8 +127,8 @@
 		leftSlider:SetHook ("OnLeave", function() return true end)
 		
 		local leftSliderThumpTexture = leftSlider:CreateTexture (nil, "overlay")
-		leftSliderThumpTexture:SetTexture (1, 1, 1)
-		leftSliderThumpTexture:SetWidth (3)
+		leftSliderThumpTexture:SetColorTexture (1, 1, 1)
+		leftSliderThumpTexture:SetWidth (1)
 		leftSliderThumpTexture:SetHeight (512)
 		leftSlider:SetThumbTexture (leftSliderThumpTexture)
 		
@@ -146,7 +146,7 @@
 		local rightCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageRightCoord")
 		rightCoordTexture:SetPoint ("topright", window, "topright", 0, 0)
 		rightCoordTexture:SetPoint ("bottomright", window, "bottomright", 0, 0)
-		rightCoordTexture.color = "red"
+		rightCoordTexture:SetColorTexture (1, 0, 0)
 		rightCoordTexture.width = 1
 		rightCoordTexture.alpha = .2
 		
@@ -158,8 +158,8 @@
 		rightSlider:SetHook ("OnLeave", function() return true end)
 		--[
 		local rightSliderThumpTexture = rightSlider:CreateTexture (nil, "overlay")
-		rightSliderThumpTexture:SetTexture (1, 1, 1)
-		rightSliderThumpTexture:SetWidth (3)
+		rightSliderThumpTexture:SetColorTexture (1, 1, 1)
+		rightSliderThumpTexture:SetWidth (1)
 		rightSliderThumpTexture:SetHeight (512)
 		rightSlider:SetThumbTexture (rightSliderThumpTexture)
 		--]]
@@ -399,9 +399,98 @@
 		flipButtonH:SetPoint ("topright", buttonsBackground, "topright", -8, -140)
 		flipButtonH:InstallCustomTexture()
 		--
-		local flipButtonV = DF:NewButton (buttonsBackground, nil, "$parentFlipButton2", nil, 100, 20, flip, 2, nil, nil, "Flip V", 1)
-		flipButtonV:SetPoint ("topright", buttonsBackground, "topright", -8, -160)
-		flipButtonV:InstallCustomTexture()
+
+		
+	--> select area to crop
+		local DragFrame = CreateFrame ("frame", nil, background_frame)
+		DragFrame:EnableMouse (false)
+		DragFrame:SetFrameStrata ("TOOLTIP")
+		DragFrame:SetPoint ("topleft", edit_texture.widget, "topleft")
+		DragFrame:SetPoint ("bottomright", edit_texture.widget, "bottomright")
+		DragFrame:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Worldmap\UI-QuestBlob-Inside]], tileSize = 256, tile = true})
+		DragFrame:SetBackdropColor (1, 1, 1, .2)
+		DragFrame:Hide()
+		
+		local SelectionBox_Up = DragFrame:CreateTexture (nil, "overlay")
+		SelectionBox_Up:SetHeight (1)
+		SelectionBox_Up:SetColorTexture (1, 1, 1)
+		local SelectionBox_Down = DragFrame:CreateTexture (nil, "overlay")
+		SelectionBox_Down:SetHeight (1)		
+		SelectionBox_Down:SetColorTexture (1, 1, 1)
+		local SelectionBox_Left = DragFrame:CreateTexture (nil, "overlay")
+		SelectionBox_Left:SetWidth (1)
+		SelectionBox_Left:SetColorTexture (1, 1, 1)
+		local SelectionBox_Right = DragFrame:CreateTexture (nil, "overlay")
+		SelectionBox_Right:SetWidth (1)
+		SelectionBox_Right:SetColorTexture (1, 1, 1)
+		
+		function DragFrame.ClearSelectionBoxPoints()
+			SelectionBox_Up:ClearAllPoints()
+			SelectionBox_Down:ClearAllPoints()
+			SelectionBox_Left:ClearAllPoints()
+			SelectionBox_Right:ClearAllPoints()
+		end
+		
+		local StartCrop = function()
+			DragFrame:Show()
+			DragFrame:EnableMouse (true)
+		end
+		
+		local CropSelection = DF:NewButton (buttonsBackground, nil, "$parentCropSelection", nil, 100, 20, StartCrop, 2, nil, nil, "Crop Selection", 1)
+		--CropSelection:SetPoint ("topright", buttonsBackground, "topright", -8, -260)
+		CropSelection:InstallCustomTexture()
+		
+		DragFrame.OnTick = function (self, deltaTime)
+			local x1, y1 = unpack (self.ClickedAt)
+			local x2, y2 = GetCursorPosition()
+			DragFrame.ClearSelectionBoxPoints()
+			
+			print (x1, y1, x2, y2)
+			
+			if (x2 > x1) then
+				--right
+				if (y1 > y2) then
+					--top
+					SelectionBox_Up:SetPoint ("topleft", UIParent, "bottomleft", x1, y1)
+					SelectionBox_Up:SetPoint ("topright", UIParent, "bottomleft", x2, y1)
+					
+					SelectionBox_Left:SetPoint ("topleft", UIParent, "bottomleft", x1, y1)
+					SelectionBox_Left:SetPoint ("bottomleft", UIParent, "bottomleft", x1, y2)
+					
+					print (1)
+				else
+					--bottom
+					
+				end
+			else
+				--left
+				if (y2 > y1) then
+					--top
+					
+				else
+					--bottom
+					
+				end
+			end
+			
+		end
+		
+		DragFrame:SetScript ("OnMouseDown", function (self, MouseButton)
+			if (MouseButton == "LeftButton") then
+				self.ClickedAt = {GetCursorPosition()}
+				DragFrame:SetScript ("OnUpdate", DragFrame.OnTick)
+				
+			end
+		end)
+		DragFrame:SetScript ("OnMouseUp", function (self, MouseButton)
+			if (MouseButton == "LeftButton") then
+				self.ReleaseAt = {GetCursorPosition()}
+				DragFrame:EnableMouse (false)
+				DragFrame:Hide()
+				DragFrame:SetScript ("OnUpdate", nil)
+				print (self.ClickedAt[1], self.ClickedAt[2], self.ReleaseAt[1], self.ReleaseAt[2])
+			end
+		end)
 		
 	--> accept
 		window.accept = function (self, b, keep_editing)
--- a/Libs/DF/textentry.lua	Mon May 08 14:58:23 2017 -0300
+++ b/Libs/DF/textentry.lua	Wed Jul 05 15:20:21 2017 -0300
@@ -369,7 +369,7 @@
 	local OnEnterPressed = function (textentry, byScript)
 		local capsule = textentry.MyObject
 	
-		local kill = capsule:RunHooksForWidget ("OnEnterPressed", textentry, capsule)
+		local kill = capsule:RunHooksForWidget ("OnEnterPressed", textentry, capsule, capsule.text)
 		if (kill) then
 			return
 		end
@@ -398,7 +398,7 @@
 	local OnEscapePressed = function (textentry)
 		local capsule = textentry.MyObject
 	
-		local kill = capsule:RunHooksForWidget ("OnEscapePressed", textentry, capsule)
+		local kill = capsule:RunHooksForWidget ("OnEscapePressed", textentry, capsule, capsule.text)
 		if (kill) then
 			return
 		end	
@@ -422,7 +422,7 @@
 	
 		if (textentry:IsShown()) then
 		
-			local kill = capsule:RunHooksForWidget ("OnEditFocusLost", textentry, capsule)
+			local kill = capsule:RunHooksForWidget ("OnEditFocusLost", textentry, capsule, capsule.text)
 			if (kill) then
 				return
 			end