From 9c67d41ad657de4d1cec21cfd43f1990d30cfc35 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Sun, 29 Jul 2012 20:34:20 +0100 Subject: [PATCH] Neaten a little bit of code --- src/interface/Textbox.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/interface/Textbox.cpp b/src/interface/Textbox.cpp index 29e36a318..d53ebeb3d 100644 --- a/src/interface/Textbox.cpp +++ b/src/interface/Textbox.cpp @@ -348,11 +348,11 @@ void Textbox::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool } if(inputType == Number) { - if(backingText.length()>1) - { - while(backingText[0] == '0') - backingText.erase(backingText.begin()); - } + //Remove extra preceding 0's + while(backingText[0] == '0' && backingText.length()>1) + backingText.erase(backingText.begin()); + + //If there is no content, replace with 0 if(!backingText.length()) backingText = "0"; }