Added: clear_on_escape property to edit box

--HG--
branch : develop
hg/compatibility-develop
Nimetu 7 years ago
parent 71d969c40b
commit 455a923031

@ -264,6 +264,7 @@ namespace NLGUI
// because of multiline, thz parent container will be moved to top
// The good position can be restored by a press on enter then
bool _WantReturn : 1; // Want return char, don't call the enter action handler
bool _ClearOnEscape : 1; // clear content when ESC is pressed?
bool _Savable : 1; // should content be saved ?
bool _DefaultInputString : 1; // Is the current input string the default one (should not be edited)
bool _Frozen : 1; // is the control frozen? (cannot edit in it)

@ -77,6 +77,7 @@ namespace NLGUI
_ResetFocusOnHide(false),
_BackupFatherContainerPos(false),
_WantReturn(false),
_ClearOnEscape(false),
_Savable(true),
_DefaultInputString(false),
_Frozen(false),
@ -239,6 +240,11 @@ namespace NLGUI
return toString( _WantReturn );
}
else
if( name == "clear_on_escape" )
{
return toString( _ClearOnEscape );
}
else
if( name == "savable" )
{
return toString( _Savable );
@ -413,6 +419,14 @@ namespace NLGUI
return;
}
else
if( name == "clear_on_escape" )
{
bool b;
if( fromString( value, b ) )
_ClearOnEscape = b;
return;
}
else
if( name == "savable" )
{
bool b;
@ -514,6 +528,7 @@ namespace NLGUI
xmlSetProp( node, BAD_CAST "backup_father_container_pos",
BAD_CAST toString( _BackupFatherContainerPos ).c_str() );
xmlSetProp( node, BAD_CAST "want_return", BAD_CAST toString( _WantReturn ).c_str() );
xmlSetProp( node, BAD_CAST "clear_on_escape", BAD_CAST toString( _ClearOnEscape ).c_str() );
xmlSetProp( node, BAD_CAST "savable", BAD_CAST toString( _Savable ).c_str() );
xmlSetProp( node, BAD_CAST "max_float_prec", BAD_CAST toString( _MaxFloatPrec ).c_str() );
@ -620,6 +635,9 @@ namespace NLGUI
prop = (char*) xmlGetProp( cur, (xmlChar*)"want_return" );
if (prop) _WantReturn = convertBool(prop);
prop = (char*) xmlGetProp( cur, (xmlChar*)"clear_on_escape" );
if (prop) _ClearOnEscape = convertBool(prop);
prop = (char*) xmlGetProp( cur, (xmlChar*)"savable" );
if (prop) _Savable = convertBool(prop);
@ -991,6 +1009,11 @@ namespace NLGUI
// stop selection
_CurrSelection = NULL;
_CursorAtPreviousLineEnd = false;
if (_ClearOnEscape)
{
setInputString(ucstring(""));
triggerOnChangeAH();
}
break;
case KeyTAB:
makeTopWindow();

@ -2655,6 +2655,7 @@
fontsize="10"
backup_father_container_pos="false"
want_return="false"
clear_on_escape="false"
color="255 255 255 255"
continuous_text_update="false"
bg_texture="W_box_blank.tga"
@ -2695,6 +2696,7 @@
menu_r="#menu_r"
max_historic="#max_historic"
want_return="#want_return"
clear_on_escape="#clear_on_escape"
backup_father_container_pos="#backup_father_container_pos"
on_focus_lost="#on_focus_lost"
on_focus_lost_params="#on_focus_lost_params"

Loading…
Cancel
Save