Same as original

Revision:
8:479ed9f0ba20
Parent:
7:6913aebb3905
Child:
9:0573d8a9bbcd
--- a/button_group.cpp	Fri Dec 11 14:23:01 2015 +0000
+++ b/button_group.cpp	Wed Dec 23 07:24:48 2015 +0000
@@ -1,7 +1,7 @@
 //-----------------------------------------------------------
 //  Button group class
 //
-//  2015/12/11, Copyright (c) 2015 MIKAMI, Naoki
+//  2015/12/23, Copyright (c) 2015 MIKAMI, Naoki
 //-----------------------------------------------------------
 
 #include "button_group.hpp"
@@ -67,13 +67,13 @@
     // Get touched number and redraw button if touched
     bool ButtonGroup::GetTouchedNumber(int &num, uint32_t color)
     {
+        if ((num<0) || (num>=numberOfButtons_)) return false;
+
+        int tmp = num;
         if (GetTouchedNumber(num))
         {
-            for (int n=0; n<numberOfButtons_; n++)
-                if (n == num)
-                    buttons_[n]->Draw(color);
-                else
-                    buttons_[n]->Redraw();
+            buttons_[num]->Draw(color);
+            buttons_[tmp]->Redraw();
             return true;
         }
         else