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

Use placeholder for E2 search text #3066

Merged
merged 4 commits into from
May 13, 2024
Merged
Changes from 3 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
40 changes: 2 additions & 38 deletions lua/wire/client/wire_expression2_browser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,6 @@ local invalid_filename_chars = {
[" "] = "_",
}

local function GetFileName(name)
local name = string.Replace(name, ".txt", "")
return string.Replace(name, "/", "")
end

local function InternalDoClick(self)
self:GetRoot():SetSelectedItem(self)
if (self:DoClick()) then return end
if (self:GetRoot():DoClick(self)) then return end
end

local function InternalDoRightClick(self)
self:GetRoot():SetSelectedItem(self)
if (self:DoRightClick()) then return end
if (self:GetRoot():DoRightClick(self)) then return end
end

local function fileName(filepath)
return string.match(filepath, "[/\\]?([^/\\]*)$")
end
Expand Down Expand Up @@ -147,44 +130,25 @@ function PANEL:StartSearch( str )
end

function PANEL:Init()
self:SetDrawBackground(false)
self:SetPaintBackground(false)

self.SearchBox = vgui.Create( "DTextEntry", self )
self.SearchBox:Dock( TOP )
self.SearchBox:DockMargin( 0,0,0,0 )
self.SearchBox:SetValue( "Search..." )
self.SearchBox:SetPlaceholderText( "Search..." )
wrefgtzweve marked this conversation as resolved.
Show resolved Hide resolved

local clearsearch = vgui.Create( "DImageButton", self.SearchBox )
clearsearch:SetMaterial( "icon16/cross.png" )
local src = self.SearchBox
function clearsearch:DoClick()
src:SetValue( "" )
src:OnEnter()
src:SetValue( "Search..." )
end
clearsearch:DockMargin( 2,2,4,2 )
clearsearch:Dock( RIGHT )
clearsearch:SetSize( 14, 10 )
clearsearch:SetVisible( false )


local old = self.SearchBox.OnGetFocus
function self.SearchBox:OnGetFocus()
if self:GetValue() == "Search..." then -- If "Search...", erase it
self:SetValue( "" )
end
old( self )
end

-- On lose focus
local old = self.SearchBox.OnLoseFocus
function self.SearchBox:OnLoseFocus()
if self:GetValue() == "" then -- if empty, reset "Search..." text
timer.Simple( 0, function() self:SetValue( "Search..." ) end )
end
old( self )
end

function self.SearchBox.OnEnter()
local str = self.SearchBox:GetValue()

Expand Down
Loading