diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /vgui2/dme_controls/filtercombobox.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'vgui2/dme_controls/filtercombobox.cpp')
| -rw-r--r-- | vgui2/dme_controls/filtercombobox.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/vgui2/dme_controls/filtercombobox.cpp b/vgui2/dme_controls/filtercombobox.cpp new file mode 100644 index 0000000..24f51c4 --- /dev/null +++ b/vgui2/dme_controls/filtercombobox.cpp @@ -0,0 +1,53 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#include "dme_controls/filtercombobox.h" + + +using namespace vgui; + + +//----------------------------------------------------------------------------- +// Constructor +//----------------------------------------------------------------------------- +CFilterComboBox::CFilterComboBox( Panel *parent, const char *panelName, int numLines, bool allowEdit ) : + BaseClass( parent, panelName, numLines, allowEdit ) +{ +} + +//----------------------------------------------------------------------------- +// Purpose: panel lost focus message +//----------------------------------------------------------------------------- +void CFilterComboBox::OnKillFocus() +{ + int nLength = GetTextLength(); + char *pFilterText = (char*)_alloca( (nLength+1) * sizeof(char) ); + GetText( pFilterText, nLength+1 ); + + // Remove the existing version in the list + char pItemText[512]; + int nItemCount = GetItemCount(); + int i; + for ( i = 0; i < nItemCount; ++i ) + { + GetItemText( i, pItemText, sizeof(pItemText) ); + if ( !Q_stricmp( pFilterText, pItemText ) ) + break; + } + + if ( i != nItemCount ) + { + // Remove the existing copy + DeleteItem( i ); + } + + AddItem( pFilterText, NULL ); + + BaseClass::OnKillFocus( ); +} + + + |