editbox refactoring
This commit is contained in:
@@ -284,6 +284,23 @@ function m.editbox(parent, name)
|
||||
editbox:SetBackdropColor(unpack(m.config.content_color))
|
||||
editbox:SetBackdropBorderColor(unpack(m.config.content_border_color))
|
||||
|
||||
editbox:SetScript('OnEscapePressed', function()
|
||||
this:HighlightText(0, 0)
|
||||
this:ClearFocus()
|
||||
end)
|
||||
|
||||
local last_time, last_x, last_y
|
||||
editbox:SetScript('OnMouseUp', function()
|
||||
local x, y = GetCursorPosition()
|
||||
if last_time and last_time > GetTime() - .5 and abs(x - last_x) < 10 and abs(y - last_y) < 10 then
|
||||
this:HighlightText()
|
||||
last_time = nil
|
||||
else
|
||||
last_time = GetTime()
|
||||
last_x, last_y = GetCursorPosition()
|
||||
end
|
||||
end)
|
||||
|
||||
-- local label = frame:CreateFontString(nil, 'OVERLAY')
|
||||
-- label:SetPoint('TOPLEFT', 0, -2)
|
||||
-- label:SetPoint('TOPRIGHT', 0, -2)
|
||||
|
||||
@@ -272,12 +272,6 @@ function public.on_load()
|
||||
private.write_settings(settings)
|
||||
end
|
||||
end)
|
||||
slider.editbox:SetScript('OnEscapePressed', function()
|
||||
this:ClearFocus()
|
||||
end)
|
||||
slider.editbox:SetScript('OnEditFocusGained', function()
|
||||
this:HighlightText()
|
||||
end)
|
||||
slider.editbox:SetScript('OnEditFocusLost', function()
|
||||
this:HighlightText(0, 0)
|
||||
end)
|
||||
@@ -309,12 +303,6 @@ function public.on_load()
|
||||
slider:SetValue(this:GetNumber())
|
||||
private.quantity_update()
|
||||
end)
|
||||
slider.editbox:SetScript('OnEscapePressed', function()
|
||||
this:ClearFocus()
|
||||
end)
|
||||
slider.editbox:SetScript('OnEditFocusGained', function()
|
||||
this:HighlightText()
|
||||
end)
|
||||
slider.editbox:SetScript('OnEditFocusLost', function()
|
||||
this:HighlightText(0, 0)
|
||||
end)
|
||||
@@ -384,12 +372,6 @@ function public.on_load()
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
end)
|
||||
editbox:SetScript('OnEscapePressed', function()
|
||||
this:ClearFocus()
|
||||
end)
|
||||
editbox:SetScript('OnEditFocusGained', function()
|
||||
this:HighlightText()
|
||||
end)
|
||||
editbox:SetScript('OnEditFocusLost', function()
|
||||
this:SetText(Aux.money.to_string(private.get_unit_start_price(), true, nil, 3))
|
||||
end)
|
||||
@@ -425,12 +407,6 @@ function public.on_load()
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
end)
|
||||
editbox:SetScript('OnEscapePressed', function()
|
||||
this:ClearFocus()
|
||||
end)
|
||||
editbox:SetScript('OnEditFocusGained', function()
|
||||
this:HighlightText()
|
||||
end)
|
||||
editbox:SetScript('OnEditFocusLost', function()
|
||||
this:SetText(Aux.money.to_string(private.get_unit_buyout_price(), true, nil, 3))
|
||||
end)
|
||||
|
||||
@@ -257,26 +257,6 @@ function public.on_load()
|
||||
this:ClearFocus()
|
||||
public.start_search()
|
||||
end)
|
||||
editbox:SetScript('OnEscapePressed', function()
|
||||
this:HighlightText(0, 0)
|
||||
this:ClearFocus()
|
||||
end)
|
||||
editbox:SetScript('OnEditFocusGained', function()
|
||||
this:HighlightText()
|
||||
end)
|
||||
do
|
||||
local last_time, last_x, last_y
|
||||
editbox:SetScript('OnMouseUp', function()
|
||||
local x, y = GetCursorPosition()
|
||||
if last_time and last_time > GetTime() - .5 and abs(x - last_x) < 10 and abs(y - last_y) < 10 then
|
||||
this:HighlightText()
|
||||
last_time = nil
|
||||
else
|
||||
last_time = GetTime()
|
||||
last_x, last_y = GetCursorPosition()
|
||||
end
|
||||
end)
|
||||
end
|
||||
editbox:SetScript('OnReceiveDrag', function()
|
||||
local item_info = Aux.cursor_item() and Aux.info.item(Aux.cursor_item().item_id)
|
||||
if item_info then
|
||||
@@ -425,12 +405,6 @@ function public.on_load()
|
||||
this:ClearFocus()
|
||||
public.start_search()
|
||||
end)
|
||||
editbox:SetScript('OnEscapePressed', function()
|
||||
this:ClearFocus()
|
||||
end)
|
||||
editbox:SetScript('OnEditFocusGained', function()
|
||||
this:HighlightText()
|
||||
end)
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
|
||||
label:SetText('Name')
|
||||
@@ -462,12 +436,6 @@ function public.on_load()
|
||||
this:ClearFocus()
|
||||
public.start_search()
|
||||
end)
|
||||
editbox:SetScript('OnEscapePressed', function()
|
||||
this:ClearFocus()
|
||||
end)
|
||||
editbox:SetScript('OnEditFocusGained', function()
|
||||
this:HighlightText()
|
||||
end)
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
|
||||
label:SetText('Level Range')
|
||||
@@ -489,12 +457,6 @@ function public.on_load()
|
||||
this:ClearFocus()
|
||||
public.start_search()
|
||||
end)
|
||||
editbox:SetScript('OnEscapePressed', function()
|
||||
this:ClearFocus()
|
||||
end)
|
||||
editbox:SetScript('OnEditFocusGained', function()
|
||||
this:HighlightText()
|
||||
end)
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('RIGHT', editbox, 'LEFT', -3, 0)
|
||||
label:SetText('-')
|
||||
@@ -729,12 +691,6 @@ function public.on_load()
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
on_click()
|
||||
end)
|
||||
editbox:SetScript('OnEscapePressed', function()
|
||||
this:ClearFocus()
|
||||
end)
|
||||
editbox:SetScript('OnEditFocusGained', function()
|
||||
this:HighlightText()
|
||||
end)
|
||||
tinsert(btn.inputs, editbox)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user