post selection improvements

This commit is contained in:
Manuel Simon Hirsig
2017-02-10 13:03:00 +01:00
parent f108aa14c2
commit af696e41e8
4 changed files with 43 additions and 33 deletions
+6 -19
View File
@@ -28,7 +28,7 @@ local handlers = {
OnLeave = function()
this.mouseover = false
if not this.data then return end
if not this.st.selected or this.st.selected ~= key(this.st.rowData, this.data) then
if not (this.st.selected and this.st.selected(this.data)) then
this.highlight:Hide()
end
@@ -40,10 +40,6 @@ local handlers = {
OnClick = function()
if not this.data then return end
this.st:ClearSelection()
this.st.selected = not this.st.selectionDisabled and key(this.st.rowData, this.data)
this.highlight:Show()
local handler = this.st.handlers.OnClick
if handler then
handler(this.st, this.data, this, arg1)
@@ -132,7 +128,7 @@ local methods = {
if not data then break end
self.rows[i].data = data
if self.selected == key(self.rowData, data) or self.rows[i].mouseover then
if self.rows[i].mouseover or self.selected and self.selected(data) then
self.rows[i].highlight:Show()
else
self.rows[i].highlight:Hide()
@@ -163,19 +159,6 @@ local methods = {
self:Update()
end,
GetSelection = function(self)
return self.rowData[self.selected]
end,
ClearSelection = function(self)
self.selected = nil
self:Update()
end,
DisableSelection = function(self, value)
self.selectionDisabled = value
end,
AddColumn = function(self)
local colNum = getn(self.headCols) + 1
local col = CreateFrame('Frame', nil, self.contentFrame)
@@ -258,6 +241,10 @@ local methods = {
end
end,
SetSelection = function(self, f)
self.selected = f
end,
SetHandler = function(self, event, handler)
self.handlers[event] = handler
end,