diff Button.lua @ 299:e337b39dc491

Add ExtraActionButton support
author Flick
date Wed, 14 Nov 2012 16:38:53 -0800
parents 7a9e82c0df15
children
line wrap: on
line diff
--- a/Button.lua	Wed Nov 14 16:35:18 2012 -0800
+++ b/Button.lua	Wed Nov 14 16:38:53 2012 -0800
@@ -204,6 +204,10 @@
   if not poolID or not maxID then
     error("AcquireActionID: must setup pool first with SetActionIDPool")
   end
+  hint = tonumber(hint)
+  if hint and (hint < 1 or hint > maxID) then
+    hint = nil
+  end
   local pool = idPools[poolID]
   if not pool then
     pool = { nWraps = 0, useCount = { } }
@@ -216,19 +220,19 @@
   if id == nil then
     repeat
       local nWraps = pool.nWraps or 0
-      if hint and (useCount[hint] == nil or useCount[hint] == nWraps) then
+      if hint and (useCount[hint] == 0 or useCount[hint] == nWraps) then
         id = hint
       else
         local start = hint or 1
         for i = start, maxID do
-          if useCount[i] == nil or useCount[i] == nWraps then
+          if useCount[i] == 0 or useCount[i] == nWraps then
             id = i
             break
           end
         end
         if not id then
           for i = 1, start do
-            if useCount[i] == nil or useCount[i] == nWraps then
+            if useCount[i] == 0 or useCount[i] == nWraps then
               id = i
               break
             end