Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take into account the detail value when searching in a DropDown control #7844

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/Classes/DropDownControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ local DropDownClass = newClass("DropDownControl", "Control", "ControlHost", "Too
end,
-- value mapping function
function(listVal)
return StripEscapes(type(listVal) == "table" and listVal.label or listVal)
if type(listVal) == "table" then
return StripEscapes(listVal.detail == nil and listVal.label or listVal.label .. " " .. listVal.detail)
else
return StripEscapes(listVal)
end
end
)
self.controls.scrollBar = new("ScrollBarControl", {"TOPRIGHT",self,"TOPRIGHT"}, -1, 0, 18, 0, (height - 4) * 4)
Expand Down Expand Up @@ -359,10 +363,16 @@ function DropDownClass:Draw(viewPort, noTooltip)
SetDrawColor(0.66, 0.66, 0.66)
end
-- draw actual item label with search match highlight if available
local label = type(listVal) == "table" and listVal.label or listVal
local label
local detail
if type(listVal) == "table" then
label = listVal.label
detail = listVal.detail
else
label = listVal
end
DrawString(0, y, "LEFT", lineHeight, "VAR", label)
if selDetail ~= nil then
local detail = listVal.detail
if detail ~= nil then
dx = DrawStringWidth(lineHeight, "VAR", detail)
DrawString(width - dx - 4 - 22, y, "LEFT", lineHeight, "VAR", detail)
end
Expand Down
Loading