reverted some editbox changes as it seems coloring while typing cannot be done properly in vanilla

This commit is contained in:
Manuel Simon Hirsig
2016-09-19 09:17:50 +02:00
parent 1d87e2cbac
commit 7f7d723e1c
2 changed files with 15 additions and 42 deletions
+13 -40
View File
@@ -300,39 +300,30 @@ function public.editbox(parent)
editbox:SetTextInsets(1.5, 1.5, 3, 3) editbox:SetTextInsets(1.5, 1.5, 3, 3)
editbox:SetMaxLetters(nil) editbox:SetMaxLetters(nil)
editbox:SetHeight(24) editbox:SetHeight(24)
editbox:SetTextColor(0, 0, 0, 0)
set_content_style(editbox) set_content_style(editbox)
local function colorize() this.display:SetText((this.colorizer or id)(this:GetText())) end
local function format() this.display:SetText((this.formatter or this.colorizer or id)(this:GetText())) end
editbox:SetScript('OnEscapePressed', function() editbox:SetScript('OnEscapePressed', function()
this:ClearFocus() this:ClearFocus()
;(this.escape or nop)() ;(this.escape or nop)()
end) end)
editbox:SetScript('OnEnterPressed', function() (this.enter or nop)() end) editbox:SetScript('OnEnterPressed', function() (this.enter or nop)() end)
editbox:SetScript('OnEditFocusGained', function() editbox:SetScript('OnEditFocusGained', function()
colorize() this.overlay:Hide()
this:SetTextColor(color.text.enabled())
this.focused = true this.focused = true
this:HighlightText() this:HighlightText()
this:SetScript('OnUpdate', function()
this.cursor:SetAlpha(mod(floor((GetTime() - this.cursor.last_change) * 2 + 1), 2))
end)
;(this.focus_gain or nop)() ;(this.focus_gain or nop)()
end) end)
editbox:SetScript('OnEditFocusLost', function() editbox:SetScript('OnEditFocusLost', function()
format() this.overlay:Show()
this:SetTextColor(0, 0, 0, 0)
this.focused = false this.focused = false
this.cursor:SetAlpha(0)
this:HighlightText(0, 0) this:HighlightText(0, 0)
this:SetScript('OnUpdate', nil) this:SetScript('OnUpdate', nil)
;(this.focus_loss or nop)() ;(this.focus_loss or nop)()
end) end)
editbox:SetScript('OnTextChanged', function() editbox:SetScript('OnTextChanged', function()
if this.focused then colorize() else format() end this.overlay:SetText((this.formatter or id)(this:GetText()))
(this.change or nop)() ;(this.change or nop)()
end)
editbox:SetScript('OnCursorChanged', function()
this.cursor.last_change = GetTime()
this.cursor:SetPoint(this:GetJustifyH(), this, this:GetJustifyH(), (arg1 > 0 and max or min)(0, arg1 - 1), 1.5)
end) end)
editbox:SetScript('OnChar', function() (this.char or nop)() end) editbox:SetScript('OnChar', function() (this.char or nop)() end)
do do
@@ -340,7 +331,6 @@ function public.editbox(parent)
editbox:SetScript('OnMouseDown', function() editbox:SetScript('OnMouseDown', function()
local x, y = GetCursorPosition() local x, y = GetCursorPosition()
-- local offset = x - editbox:GetLeft()*editbox:GetEffectiveScale() TODO use a fontstring to measure getstringwidth for structural highlighting -- local offset = x - editbox:GetLeft()*editbox:GetEffectiveScale() TODO use a fontstring to measure getstringwidth for structural highlighting
-- editbox:Insert'<ksejfkj>' TODO use insert with special tags to determine cursor position
-- or use an overlay with itemlinks -- or use an overlay with itemlinks
if GetTime() - last_click.t < .5 and x == last_click.x and y == last_click.y then if GetTime() - last_click.t < .5 and x == last_click.x and y == last_click.y then
thread(function() editbox:HighlightText() end) thread(function() editbox:HighlightText() end)
@@ -349,38 +339,21 @@ function public.editbox(parent)
last_click.t = GetTime() last_click.t = GetTime()
last_click.x = x last_click.x = x
last_click.y = y last_click.y = y
-- __(last_click) :t(GetTime()) :x(x) :y(y) TODO
end) end)
end end
function editbox:Enable()
editbox:EnableMouse(true)
editbox:SetTextColor(color.text.enabled())
end
function editbox:Disable()
editbox:EnableMouse(false)
editbox:SetTextColor(color.text.disabled())
editbox:ClearFocus()
end
function editbox:SetAlignment(alignment) function editbox:SetAlignment(alignment)
self:SetJustifyH(alignment) self:SetJustifyH(alignment)
self.display:SetJustifyH(alignment) self.overlay:SetJustifyH(alignment)
end end
function editbox:SetFontSize(size) function editbox:SetFontSize(size)
self:SetFont(font, size) self:SetFont(font, size)
self.display:SetFont(font, size) self.overlay:SetFont(font, size)
end end
local display = label(editbox) local overlay = label(editbox)
display:SetPoint('LEFT', 1.5, 0) overlay:SetPoint('LEFT', 1.5, 0)
display:SetPoint('RIGHT', -1.5, 0) overlay:SetPoint('RIGHT', -1.5, 0)
display:SetTextColor(color.text.enabled()) overlay:SetTextColor(color.text.enabled())
editbox.display = display editbox.overlay = overlay
local cursor = label(editbox, 17)
cursor:SetText('|')
cursor:SetTextColor(color.text.enabled())
cursor:SetAlpha(0)
cursor.last_change = 0
editbox.cursor = cursor
editbox:SetAlignment('LEFT') editbox:SetAlignment('LEFT')
editbox:SetFontSize(font_size.medium) editbox:SetFontSize(font_size.medium)
return editbox return editbox
+2 -2
View File
@@ -81,9 +81,9 @@ function update_form()
end end
for key in temp-S('min_level', 'max_level') do for key in temp-S('min_level', 'max_level') do
if blizzard_query.exact then if blizzard_query.exact then
_E[key .. '_input']:Disable() _E[key .. '_input']:EnableMouse(false)
else else
_E[key .. '_input']:Enable() _E[key .. '_input']:EnableMouse(true)
end end
end end
if blizzard_query.exact then if blizzard_query.exact then