mirror of
https://github.com/Facepunch/sbox-public.git
synced 2025-12-23 22:48:07 -05:00
Add Label.Tokenize (turn off automatic conversion of strings starting with #)
This commit is contained in:
committed by
Matt Stevens
parent
07e1f7a2d4
commit
0533d101a8
@@ -48,6 +48,11 @@ namespace Sandbox.UI
|
||||
[Category( "Selection" )]
|
||||
public bool Selectable { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// If true and the text starts with #, it will be treated as a language token.
|
||||
/// </summary>
|
||||
public bool Tokenize { get; set; } = true;
|
||||
|
||||
[Hide]
|
||||
public int SelectionStart
|
||||
{
|
||||
@@ -150,7 +155,7 @@ namespace Sandbox.UI
|
||||
{
|
||||
value ??= "";
|
||||
|
||||
if ( value != null && value.Length > 1 && value[0] == '#' )
|
||||
if ( Tokenize && value != null && value.Length > 1 && value[0] == '#' )
|
||||
{
|
||||
if ( _textToken == value ) return;
|
||||
_textToken = value;
|
||||
@@ -417,6 +422,7 @@ namespace Sandbox.UI
|
||||
public override void LanguageChanged()
|
||||
{
|
||||
if ( _textToken == null ) return;
|
||||
if ( !Tokenize ) return;
|
||||
|
||||
var token = _textToken;
|
||||
_textToken = null; // skip cache
|
||||
|
||||
Reference in New Issue
Block a user