resources/scenemain.lua

changeset 0
7ff85f7ce3a7
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/resources/scenemain.lua	Wed Jul 31 19:28:00 2013 +0200
     1.3 @@ -0,0 +1,2587 @@
     1.4 +-- Initiate scene management
     1.5 +local sceneloc = director:createScene()
     1.6 +sceneloc.name = 'Scene: Main'
     1.7 +
     1.8 +-- Database instantiated
     1.9 +local debe
    1.10 +local pathStor = system:getFilePath('storage')
    1.11 +debe = sqlite3.open(pathStor .. 'amalog.sql')
    1.12 +debe:exec[=[
    1.13 +    CREATE TABLE qsos(id INTEGER PRIMARY KEY, call TEXT);
    1.14 +]=]
    1.15 +debe:close()
    1.16 +debe = nil
    1.17 +
    1.18 +-- Constants calculated
    1.19 +local dsw = director.displayWidth
    1.20 +local dsh = director.displayHeight
    1.21 +local dmw = director.displayCenterX
    1.22 +local dmh = director.displayCenterY
    1.23 +
    1.24 +-- Fonts created
    1.25 +local fontsegoe = director:createFont('fonts/SegoeUI-92pt_smbld.fnt')
    1.26 +local fontarial = director:createFont('fonts/Arial-96pt_bold.fnt')
    1.27 +
    1.28 +-- Tables of indexed and marked db rows
    1.29 +local dbIdx = {0, 0, 0, 0, 0, 0, 0}
    1.30 +local dbMrk = {0, 0, 0, 0, 0, 0, 0}
    1.31 +
    1.32 +-- Scrolling index
    1.33 +local nScroll = 0
    1.34 +
    1.35 +-- Scrolling placeholder
    1.36 +local posMove = 0
    1.37 +
    1.38 +function sceneloc:setUp(event)
    1.39 +    dbg.print('sceneloc:setUp')
    1.40 +    --self.obj0 = director:createLabel(4, dh/2, 'MAIN MENU')
    1.41 +    --self.obj1 = director:createRectangle(
    1.42 +
    1.43 +    -- Print background
    1.44 +    local imgback = director:createSprite(0, dsh - fontarial.height * 12, 'textures/skynorm.png')
    1.45 +    imgback.xScale = dsw / imgback.w
    1.46 +    imgback.yScale = fontarial.height * 10.5 / imgback.h
    1.47 +
    1.48 +    -- Declare defaults
    1.49 +    --director:setNodesColor(32, 32, 32, 128)
    1.50 +    --director:setNodesColor(112, 128, 144, 255)
    1.51 +    director:setNodesColor(192, 192, 192)
    1.52 +
    1.53 +    -- Heading labels
    1.54 +    --    x=0, y=dsh-fontarial.height,
    1.55 +    --    x=dsw/2, y=dsh-fontarial.height,
    1.56 +    --    textTouchableBorder=0
    1.57 +    local labnull = director:createLabel()
    1.58 +    --labnull.isVisible = false
    1.59 +    --    x=-dsw/4, y=-fontarial.height*1.5/6,
    1.60 +    --    x=dsw/4, y=-fontarial.height*1.5/6,
    1.61 +    --    hAlignment='centre', vAlignment='top',
    1.62 +    local labtitle = director:createLabel({
    1.63 +        x=0, y=-fontarial.height*1.5/6,
    1.64 +        hAlignment='centre', vAlignment='top',
    1.65 +        font=fontarial,
    1.66 +        text='Amalog',
    1.67 +        color={0xe0, 0xe0, 0xff}
    1.68 +    })
    1.69 +    local butabout = director:createSprite(0, 0, 'images/buttinfo.png')
    1.70 +    butabout.x = fontarial.height*1.5/2
    1.71 +    butabout.y = dsh-fontarial.height*1.5/2
    1.72 +    butabout.xAnchor = 0.5
    1.73 +    butabout.yAnchor = 0.5
    1.74 +    local buthelp = director:createSprite(0, 0, 'images/butthelp.png')
    1.75 +    buthelp.x = dsw-fontarial.height*1.5/2
    1.76 +    buthelp.y = dsh-fontarial.height*1.5/2
    1.77 +    buthelp.xAnchor = 0.5
    1.78 +    buthelp.yAnchor = 0.5
    1.79 +    --tween:dissolve(labnull, butabout, 1, 0)
    1.80 +    --tween:dissolve(labnull, buthelp, 1, 0)
    1.81 +
    1.82 +    --local rectest = director:createRectangle(0, (dsh - fontarial.height * 4.5), dsw, fontarial.height * 1.5)
    1.83 +    rectoddy = director:createRectangle(0, (dsh - fontarial.height * 3), dsw, fontarial.height * 1.5)
    1.84 +    --rectoddy.color = color.black; rectoddy.color.a = 224;
    1.85 +    rectoddy.color = color.lightGrey
    1.86 +    recteven = director:createRectangle(0, (dsh - fontarial.height * 4.5), dsw, fontarial.height * 1.5)
    1.87 +    recthree = director:createRectangle(0, (dsh - fontarial.height * 6), dsw, fontarial.height * 1.5)
    1.88 +    --recthree.color = color.black; recthree.color.a = 224;
    1.89 +    recthree.color = color.lightGrey
    1.90 +    rectfour = director:createRectangle(0, (dsh - fontarial.height * 7.5), dsw, fontarial.height * 1.5)
    1.91 +    rectfive = director:createRectangle(0, (dsh - fontarial.height * 9), dsw, fontarial.height * 1.5)
    1.92 +    --rectfive.color = color.black; rectfive.color.a = 224;
    1.93 +    rectfive.color = color.lightGrey
    1.94 +    rectseis = director:createRectangle(0, (dsh - fontarial.height * 10.5), dsw, fontarial.height * 1.5)
    1.95 +    rectsieb = director:createRectangle(0, (dsh - fontarial.height * 12), dsw, fontarial.height * 1.5)
    1.96 +    --rectsieb.color = color.black; rectsieb.color.a = 224;
    1.97 +    rectsieb.color = color.lightGrey
    1.98 +
    1.99 +    ----local labtext = director:createLabel(0, 0, 'Excusez moi Welt!')
   1.100 +    --local labheight = director:createLabel({x=0, y=0, font=fontsegoe, color=color.white, text=dsh})
   1.101 +    --local labwidth  = director:createLabel({x=0, y=fontsegoe.height, font=fontsegoe, color=color.yellow, text=dsw})
   1.102 +    --local labmith  = director:createLabel({x=0, y=2*fontsegoe.height, font=fontsegoe, color=color.green, text=dmh})
   1.103 +    --local labmitw  = director:createLabel({x=0, y=3*fontsegoe.height, font=fontsegoe, color=color.blue, text=dmw})
   1.104 +
   1.105 +    function rectoddy:touch(event)
   1.106 +        if event.phase == 'began' then
   1.107 +            posMove = event.y
   1.108 +            local nBase = event.y - (dsh - fontarial.height * 12)
   1.109 +            local nRect = fontarial.height * 1.5
   1.110 +            local nTemp = nBase / nRect
   1.111 +            local nIdx  = 7 - math.floor(nTemp)
   1.112 +            if dbIdx[nIdx] == 0 then
   1.113 +                return
   1.114 +            elseif rectoddy.color.r == 240 and rectoddy.color.g == 230 and rectoddy.color.b == 140 then
   1.115 +                rectoddy.color = color.lightGrey
   1.116 +                dbMrk[nIdx] = 0
   1.117 +            else
   1.118 +                rectoddy.color = color.khaki
   1.119 +                dbMrk[nIdx] = dbIdx[nIdx]
   1.120 +            end
   1.121 +        end
   1.122 +
   1.123 +        --if event.phase == 'moved' then
   1.124 +        --    posMove = event.y
   1.125 +        --end
   1.126 +
   1.127 +        if event.phase == 'ended' then
   1.128 +            if math.abs(event.y - posMove) > fontarial.height*1.5 then
   1.129 +                -- Provide callback to count rows in table
   1.130 +                local nCount = 0
   1.131 +                function countrows(udata, cols, values, names)
   1.132 +                    assert(udata == 'dingdong')
   1.133 +                    nCount = tonumber(values[1])
   1.134 +                    return 0
   1.135 +                end
   1.136 +
   1.137 +                -- Repopulate UI conditionally
   1.138 +                debe = sqlite3.open(pathStor .. 'amalog.sql')
   1.139 +                local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
   1.140 +                debe:close()
   1.141 +                debe = nil
   1.142 +
   1.143 +                if event.y - posMove > 0 then  -- Gesture upward
   1.144 +                    if nScroll + 7 < nCount then
   1.145 +                        nScroll = nScroll + 7
   1.146 +                    else
   1.147 +                        return
   1.148 +                    end
   1.149 +                else -- Gesture downward
   1.150 +                    if nScroll - 7 >= 0 then
   1.151 +                        nScroll = nScroll - 7
   1.152 +                    else
   1.153 +                        return
   1.154 +                    end
   1.155 +                end
   1.156 +
   1.157 +                -- Kludge stucked event handlers
   1.158 +                rectoddy:removeEventListener('touch', rectoddy)
   1.159 +                recteven:removeEventListener('touch', recteven)
   1.160 +                recthree:removeEventListener('touch', recthree)
   1.161 +                rectfour:removeEventListener('touch', rectfour)
   1.162 +                rectfive:removeEventListener('touch', rectfive)
   1.163 +                rectseis:removeEventListener('touch', rectseis)
   1.164 +                rectsieb:removeEventListener('touch', rectsieb)
   1.165 +
   1.166 +                -- Clear viewport
   1.167 +                for nIter = 0, 6 do
   1.168 +                    local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
   1.169 +
   1.170 +                    function rectfresh:touch(event)
   1.171 +                        if event.phase == 'began' then
   1.172 +                            posMove = event.y
   1.173 +                            local nBase = event.y - (dsh - fontarial.height * 12)
   1.174 +                            local nRect = fontarial.height * 1.5
   1.175 +                            local nTemp = nBase / nRect
   1.176 +                            local nIdx  = 7 - math.floor(nTemp)
   1.177 +                            if dbIdx[nIdx] == 0 then
   1.178 +                                return
   1.179 +                            elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
   1.180 +                                event.target.color = color.lightGrey
   1.181 +                                dbMrk[nIdx] = 0
   1.182 +                            elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
   1.183 +                                event.target.color = {192, 192, 192}
   1.184 +                                dbMrk[nIdx] = 0
   1.185 +                            elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
   1.186 +                                event.target.color = {220, 210, 120}
   1.187 +                                dbMrk[nIdx] = dbIdx[nIdx]
   1.188 +                            else
   1.189 +                                event.target.color = color.khaki
   1.190 +                                dbMrk[nIdx] = dbIdx[nIdx]
   1.191 +                            end
   1.192 +                        end
   1.193 +                        if event.phase == 'ended' then
   1.194 +                            if math.abs(event.y - posMove) > fontarial.height*1.5 then
   1.195 +                                -- Provide callback to count rows in table
   1.196 +                                local nCount = 0
   1.197 +                                function countrows(udata, cols, values, names)
   1.198 +                                    assert(udata == 'dingdong')
   1.199 +                                    nCount = tonumber(values[1])
   1.200 +                                    return 0
   1.201 +                                end
   1.202 +                       
   1.203 +                                -- Repopulate UI conditionally
   1.204 +                                debe = sqlite3.open(pathStor .. 'amalog.sql')
   1.205 +                                local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
   1.206 +                                debe:close()
   1.207 +                                debe = nil
   1.208 +                       
   1.209 +                                if event.y - posMove > 0 then  -- Gesture upward
   1.210 +                                    if nScroll + 7 < nCount then
   1.211 +                                        nScroll = nScroll + 7
   1.212 +                                    else
   1.213 +                                        return
   1.214 +                                    end
   1.215 +                                else -- Gesture downward
   1.216 +                                    if nScroll - 7 >= 0 then
   1.217 +                                        nScroll = nScroll - 7
   1.218 +                                    else
   1.219 +                                        return
   1.220 +                                    end
   1.221 +                                end
   1.222 +                       
   1.223 +                                -- Kludge stucked event handlers
   1.224 +                                rectoddy:removeEventListener('touch', rectoddy)
   1.225 +                                recteven:removeEventListener('touch', recteven)
   1.226 +                                recthree:removeEventListener('touch', recthree)
   1.227 +                                rectfour:removeEventListener('touch', rectfour)
   1.228 +                                rectfive:removeEventListener('touch', rectfive)
   1.229 +                                rectseis:removeEventListener('touch', rectseis)
   1.230 +                                rectsieb:removeEventListener('touch', rectsieb)
   1.231 +
   1.232 +                                -- Clear viewport
   1.233 +                                for nIter = 0, 6 do
   1.234 +                                    local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
   1.235 +                       
   1.236 +                                    function rectfresh:touch(event)
   1.237 +                                        if event.phase == 'began' then
   1.238 +                                            posMove = event.y
   1.239 +                                            local nBase = event.y - (dsh - fontarial.height * 12)
   1.240 +                                            local nRect = fontarial.height * 1.5
   1.241 +                                            local nTemp = nBase / nRect
   1.242 +                                            local nIdx  = 7 - math.floor(nTemp)
   1.243 +                                            if dbIdx[nIdx] == 0 then
   1.244 +                                                return
   1.245 +                                            elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
   1.246 +                                                event.target.color = color.lightGrey
   1.247 +                                                dbMrk[nIdx] = 0
   1.248 +                                            elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
   1.249 +                                                event.target.color = {192, 192, 192}
   1.250 +                                                dbMrk[nIdx] = 0
   1.251 +                                            elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
   1.252 +                                                event.target.color = {220, 210, 120}
   1.253 +                                                dbMrk[nIdx] = dbIdx[nIdx]
   1.254 +                                            else
   1.255 +                                                event.target.color = color.khaki
   1.256 +                                                dbMrk[nIdx] = dbIdx[nIdx]
   1.257 +                                            end
   1.258 +                                        end
   1.259 +                                    end
   1.260 +                                    rectfresh:addEventListener('touch', rectfresh)
   1.261 +                       
   1.262 +                                    if nIter % 2 == 0 then
   1.263 +                                        rectfresh.color = color.lightGrey
   1.264 +                                    else
   1.265 +                                        rectfresh.color = {192, 192, 192}
   1.266 +                                    end
   1.267 +                       
   1.268 +                                    -- Clear indexes
   1.269 +                                    dbIdx[nIter+1] = 0
   1.270 +                                    dbMrk[nIter+1] = 0
   1.271 +                                end
   1.272 +                       
   1.273 +                                -- Redraw labels
   1.274 +                                local nIter = 6
   1.275 +                                --for nIter = 0, 7 do
   1.276 +                                local nTemp = nCount - nScroll
   1.277 +                                if nTemp < 7 then
   1.278 +                                    nIter = nTemp - 1
   1.279 +                                end
   1.280 +                       
   1.281 +                                debe = sqlite3.open(pathStor .. 'amalog.sql')
   1.282 +                                for dbRows in debe:nrows('SELECT * FROM qsos') do
   1.283 +                                    if nTemp < 8 then
   1.284 +                                        if nTemp < 0 then break end
   1.285 +                                        if nIter < 0 then break end
   1.286 +                                        local labrepop = director:createLabel({
   1.287 +                                            x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
   1.288 +                                            hAlignment='left', vAlignment='bottom',
   1.289 +                                            font=fontsegoe,
   1.290 +                                            text=dbRows['call']
   1.291 +                                        })
   1.292 +                                        dbIdx[nIter+1] = dbRows['id']
   1.293 +                                        nIter = nIter - 1
   1.294 +                                        nTemp = nTemp - 1
   1.295 +                                    else
   1.296 +                                        nTemp = nTemp - 1
   1.297 +                                    end
   1.298 +                                end
   1.299 +                                debe:close()
   1.300 +                                debe = nil
   1.301 +                            end
   1.302 +                            posMove = 0
   1.303 +                        end
   1.304 +                    end
   1.305 +                    rectfresh:addEventListener('touch', rectfresh)
   1.306 +
   1.307 +                    if nIter % 2 == 0 then
   1.308 +                        rectfresh.color = color.lightGrey
   1.309 +                    else
   1.310 +                        rectfresh.color = {192, 192, 192}
   1.311 +                    end
   1.312 +
   1.313 +                    -- Clear indexes
   1.314 +                    dbIdx[nIter+1] = 0
   1.315 +                    dbMrk[nIter+1] = 0
   1.316 +                end
   1.317 +
   1.318 +                -- Redraw labels
   1.319 +                local nIter = 6
   1.320 +                --for nIter = 0, 7 do
   1.321 +                local nTemp = nCount - nScroll
   1.322 +                if nTemp < 7 then
   1.323 +                    nIter = nTemp - 1
   1.324 +                end
   1.325 +
   1.326 +                debe = sqlite3.open(pathStor .. 'amalog.sql')
   1.327 +                for dbRows in debe:nrows('SELECT * FROM qsos') do
   1.328 +                    if nTemp < 8 then
   1.329 +                        if nTemp < 0 then break end
   1.330 +                        if nIter < 0 then break end
   1.331 +                        local labrepop = director:createLabel({
   1.332 +                            x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
   1.333 +                            hAlignment='left', vAlignment='bottom',
   1.334 +                            font=fontsegoe,
   1.335 +                            text=dbRows['call']
   1.336 +                        })
   1.337 +                        dbIdx[nIter+1] = dbRows['id']
   1.338 +                        nIter = nIter - 1
   1.339 +                        nTemp = nTemp - 1
   1.340 +                    else
   1.341 +                        nTemp = nTemp - 1
   1.342 +                    end
   1.343 +                end
   1.344 +                debe:close()
   1.345 +                debe = nil
   1.346 +            end
   1.347 +            posMove = 0
   1.348 +        end
   1.349 +    end
   1.350 +    rectoddy:addEventListener('touch', rectoddy)
   1.351 +
   1.352 +    function recteven:touch(event)
   1.353 +        if event.phase == 'began' then
   1.354 +            posMove = event.y
   1.355 +            local nBase = event.y - (dsh - fontarial.height * 12)
   1.356 +            local nRect = fontarial.height * 1.5
   1.357 +            local nTemp = nBase / nRect
   1.358 +            local nIdx  = 7 - math.floor(nTemp)
   1.359 +            if dbIdx[nIdx] == 0 then
   1.360 +                return
   1.361 +            elseif recteven.color.r == 220 and recteven.color.g == 210 and recteven.color.b == 120 then
   1.362 +                recteven.color = {192, 192, 192}
   1.363 +                dbMrk[nIdx] = 0
   1.364 +            else
   1.365 +                recteven.color = {220, 210, 120}
   1.366 +                dbMrk[nIdx] = dbIdx[nIdx]
   1.367 +            end
   1.368 +        end
   1.369 +
   1.370 +        if event.phase == 'ended' then
   1.371 +            if math.abs(event.y - posMove) > fontarial.height*1.5 then
   1.372 +                -- Provide callback to count rows in table
   1.373 +                local nCount = 0
   1.374 +                function countrows(udata, cols, values, names)
   1.375 +                    assert(udata == 'dingdong')
   1.376 +                    nCount = tonumber(values[1])
   1.377 +                    return 0
   1.378 +                end
   1.379 +
   1.380 +                -- Repopulate UI conditionally
   1.381 +                debe = sqlite3.open(pathStor .. 'amalog.sql')
   1.382 +                local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
   1.383 +                debe:close()
   1.384 +                debe = nil
   1.385 +
   1.386 +                if event.y - posMove > 0 then  -- Gesture upward
   1.387 +                    if nScroll + 7 < nCount then
   1.388 +                        nScroll = nScroll + 7
   1.389 +                    else
   1.390 +                        return
   1.391 +                    end
   1.392 +                else -- Gesture downward
   1.393 +                    if nScroll - 7 >= 0 then
   1.394 +                        nScroll = nScroll - 7
   1.395 +                    else
   1.396 +                        return
   1.397 +                    end
   1.398 +                end
   1.399 +
   1.400 +                -- Kludge stucked event handlers
   1.401 +                rectoddy:removeEventListener('touch', rectoddy)
   1.402 +                recteven:removeEventListener('touch', recteven)
   1.403 +                recthree:removeEventListener('touch', recthree)
   1.404 +                rectfour:removeEventListener('touch', rectfour)
   1.405 +                rectfive:removeEventListener('touch', rectfive)
   1.406 +                rectseis:removeEventListener('touch', rectseis)
   1.407 +                rectsieb:removeEventListener('touch', rectsieb)
   1.408 +
   1.409 +                -- Clear viewport
   1.410 +                for nIter = 0, 6 do
   1.411 +                    local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
   1.412 +
   1.413 +                    function rectfresh:touch(event)
   1.414 +                        if event.phase == 'began' then
   1.415 +                            posMove = event.y
   1.416 +                            local nBase = event.y - (dsh - fontarial.height * 12)
   1.417 +                            local nRect = fontarial.height * 1.5
   1.418 +                            local nTemp = nBase / nRect
   1.419 +                            local nIdx  = 7 - math.floor(nTemp)
   1.420 +                            if dbIdx[nIdx] == 0 then
   1.421 +                                return
   1.422 +                            elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
   1.423 +                                event.target.color = color.lightGrey
   1.424 +                                dbMrk[nIdx] = 0
   1.425 +                            elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
   1.426 +                                event.target.color = {192, 192, 192}
   1.427 +                                dbMrk[nIdx] = 0
   1.428 +                            elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
   1.429 +                                event.target.color = {220, 210, 120}
   1.430 +                                dbMrk[nIdx] = dbIdx[nIdx]
   1.431 +                            else
   1.432 +                                event.target.color = color.khaki
   1.433 +                                dbMrk[nIdx] = dbIdx[nIdx]
   1.434 +                            end
   1.435 +                        end
   1.436 +                        if event.phase == 'ended' then
   1.437 +                            if math.abs(event.y - posMove) > fontarial.height*1.5 then
   1.438 +                                -- Provide callback to count rows in table
   1.439 +                                local nCount = 0
   1.440 +                                function countrows(udata, cols, values, names)
   1.441 +                                    assert(udata == 'dingdong')
   1.442 +                                    nCount = tonumber(values[1])
   1.443 +                                    return 0
   1.444 +                                end
   1.445 +                       
   1.446 +                                -- Repopulate UI conditionally
   1.447 +                                debe = sqlite3.open(pathStor .. 'amalog.sql')
   1.448 +                                local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
   1.449 +                                debe:close()
   1.450 +                                debe = nil
   1.451 +                       
   1.452 +                                if event.y - posMove > 0 then  -- Gesture upward
   1.453 +                                    if nScroll + 7 < nCount then
   1.454 +                                        nScroll = nScroll + 7
   1.455 +                                    else
   1.456 +                                        return
   1.457 +                                    end
   1.458 +                                else -- Gesture downward
   1.459 +                                    if nScroll - 7 >= 0 then
   1.460 +                                        nScroll = nScroll - 7
   1.461 +                                    else
   1.462 +                                        return
   1.463 +                                    end
   1.464 +                                end
   1.465 +                       
   1.466 +                                -- Kludge stucked event handlers
   1.467 +                                rectoddy:removeEventListener('touch', rectoddy)
   1.468 +                                recteven:removeEventListener('touch', recteven)
   1.469 +                                recthree:removeEventListener('touch', recthree)
   1.470 +                                rectfour:removeEventListener('touch', rectfour)
   1.471 +                                rectfive:removeEventListener('touch', rectfive)
   1.472 +                                rectseis:removeEventListener('touch', rectseis)
   1.473 +                                rectsieb:removeEventListener('touch', rectsieb)
   1.474 +
   1.475 +                                -- Clear viewport
   1.476 +                                for nIter = 0, 6 do
   1.477 +                                    local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
   1.478 +                       
   1.479 +                                    function rectfresh:touch(event)
   1.480 +                                        if event.phase == 'began' then
   1.481 +                                            posMove = event.y
   1.482 +                                            local nBase = event.y - (dsh - fontarial.height * 12)
   1.483 +                                            local nRect = fontarial.height * 1.5
   1.484 +                                            local nTemp = nBase / nRect
   1.485 +                                            local nIdx  = 7 - math.floor(nTemp)
   1.486 +                                            if dbIdx[nIdx] == 0 then
   1.487 +                                                return
   1.488 +                                            elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
   1.489 +                                                event.target.color = color.lightGrey
   1.490 +                                                dbMrk[nIdx] = 0
   1.491 +                                            elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
   1.492 +                                                event.target.color = {192, 192, 192}
   1.493 +                                                dbMrk[nIdx] = 0
   1.494 +                                            elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
   1.495 +                                                event.target.color = {220, 210, 120}
   1.496 +                                                dbMrk[nIdx] = dbIdx[nIdx]
   1.497 +                                            else
   1.498 +                                                event.target.color = color.khaki
   1.499 +                                                dbMrk[nIdx] = dbIdx[nIdx]
   1.500 +                                            end
   1.501 +                                        end
   1.502 +                                    end
   1.503 +                                    rectfresh:addEventListener('touch', rectfresh)
   1.504 +                       
   1.505 +                                    if nIter % 2 == 0 then
   1.506 +                                        rectfresh.color = color.lightGrey
   1.507 +                                    else
   1.508 +                                        rectfresh.color = {192, 192, 192}
   1.509 +                                    end
   1.510 +                       
   1.511 +                                    -- Clear indexes
   1.512 +                                    dbIdx[nIter+1] = 0
   1.513 +                                    dbMrk[nIter+1] = 0
   1.514 +                                end
   1.515 +                       
   1.516 +                                -- Redraw labels
   1.517 +                                local nIter = 6
   1.518 +                                --for nIter = 0, 7 do
   1.519 +                                local nTemp = nCount - nScroll
   1.520 +                                if nTemp < 7 then
   1.521 +                                    nIter = nTemp - 1
   1.522 +                                end
   1.523 +                       
   1.524 +                                debe = sqlite3.open(pathStor .. 'amalog.sql')
   1.525 +                                for dbRows in debe:nrows('SELECT * FROM qsos') do
   1.526 +                                    if nTemp < 8 then
   1.527 +                                        if nTemp < 0 then break end
   1.528 +                                        if nIter < 0 then break end
   1.529 +                                        local labrepop = director:createLabel({
   1.530 +                                            x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
   1.531 +                                            hAlignment='left', vAlignment='bottom',
   1.532 +                                            font=fontsegoe,
   1.533 +                                            text=dbRows['call']
   1.534 +                                        })
   1.535 +                                        dbIdx[nIter+1] = dbRows['id']
   1.536 +                                        nIter = nIter - 1
   1.537 +                                        nTemp = nTemp - 1
   1.538 +                                    else
   1.539 +                                        nTemp = nTemp - 1
   1.540 +                                    end
   1.541 +                                end
   1.542 +                                debe:close()
   1.543 +                                debe = nil
   1.544 +                            end
   1.545 +                            posMove = 0
   1.546 +                        end
   1.547 +                    end
   1.548 +                    rectfresh:addEventListener('touch', rectfresh)
   1.549 +
   1.550 +                    if nIter % 2 == 0 then
   1.551 +                        rectfresh.color = color.lightGrey
   1.552 +                    else
   1.553 +                        rectfresh.color = {192, 192, 192}
   1.554 +                    end
   1.555 +
   1.556 +                    -- Clear indexes
   1.557 +                    dbIdx[nIter+1] = 0
   1.558 +                    dbMrk[nIter+1] = 0
   1.559 +                end
   1.560 +
   1.561 +                -- Redraw labels
   1.562 +                local nIter = 6
   1.563 +                --for nIter = 0, 7 do
   1.564 +                local nTemp = nCount - nScroll
   1.565 +                if nTemp < 7 then
   1.566 +                    nIter = nTemp - 1
   1.567 +                end
   1.568 +
   1.569 +                debe = sqlite3.open(pathStor .. 'amalog.sql')
   1.570 +                for dbRows in debe:nrows('SELECT * FROM qsos') do
   1.571 +                    if nTemp < 8 then
   1.572 +                        if nTemp < 0 then break end
   1.573 +                        if nIter < 0 then break end
   1.574 +                        local labrepop = director:createLabel({
   1.575 +                            x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
   1.576 +                            hAlignment='left', vAlignment='bottom',
   1.577 +                            font=fontsegoe,
   1.578 +                            text=dbRows['call']
   1.579 +                        })
   1.580 +                        dbIdx[nIter+1] = dbRows['id']
   1.581 +                        nIter = nIter - 1
   1.582 +                        nTemp = nTemp - 1
   1.583 +                    else
   1.584 +                        nTemp = nTemp - 1
   1.585 +                    end
   1.586 +                end
   1.587 +                debe:close()
   1.588 +                debe = nil
   1.589 +            end
   1.590 +            posMove = 0
   1.591 +        end
   1.592 +    end
   1.593 +    recteven:addEventListener('touch', recteven)
   1.594 +
   1.595 +    function recthree:touch(event)
   1.596 +        if event.phase == 'began' then
   1.597 +            posMove = event.y
   1.598 +            local nBase = event.y - (dsh - fontarial.height * 12)
   1.599 +            local nRect = fontarial.height * 1.5
   1.600 +            local nTemp = nBase / nRect
   1.601 +            local nIdx  = 7 - math.floor(nTemp)
   1.602 +            if dbIdx[nIdx] == 0 then
   1.603 +                return
   1.604 +            elseif recthree.color.r == 240 and recthree.color.g == 230 and recthree.color.b == 140 then
   1.605 +                recthree.color = color.lightGrey
   1.606 +                dbMrk[nIdx] = 0
   1.607 +            else
   1.608 +                recthree.color = color.khaki
   1.609 +                dbMrk[nIdx] = dbIdx[nIdx]
   1.610 +            end
   1.611 +        end
   1.612 +
   1.613 +        if event.phase == 'ended' then
   1.614 +            if math.abs(event.y - posMove) > fontarial.height*1.5 then
   1.615 +                -- Provide callback to count rows in table
   1.616 +                local nCount = 0
   1.617 +                function countrows(udata, cols, values, names)
   1.618 +                    assert(udata == 'dingdong')
   1.619 +                    nCount = tonumber(values[1])
   1.620 +                    return 0
   1.621 +                end
   1.622 +
   1.623 +                -- Repopulate UI conditionally
   1.624 +                debe = sqlite3.open(pathStor .. 'amalog.sql')
   1.625 +                local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
   1.626 +                debe:close()
   1.627 +                debe = nil
   1.628 +
   1.629 +                if event.y - posMove > 0 then  -- Gesture upward
   1.630 +                    if nScroll + 7 < nCount then
   1.631 +                        nScroll = nScroll + 7
   1.632 +                    else
   1.633 +                        return
   1.634 +                    end
   1.635 +                else -- Gesture downward
   1.636 +                    if nScroll - 7 >= 0 then
   1.637 +                        nScroll = nScroll - 7
   1.638 +                    else
   1.639 +                        return
   1.640 +                    end
   1.641 +                end
   1.642 +
   1.643 +                -- Kludge stucked event handlers
   1.644 +                rectoddy:removeEventListener('touch', rectoddy)
   1.645 +                recteven:removeEventListener('touch', recteven)
   1.646 +                recthree:removeEventListener('touch', recthree)
   1.647 +                rectfour:removeEventListener('touch', rectfour)
   1.648 +                rectfive:removeEventListener('touch', rectfive)
   1.649 +                rectseis:removeEventListener('touch', rectseis)
   1.650 +                rectsieb:removeEventListener('touch', rectsieb)
   1.651 +
   1.652 +                -- Clear viewport
   1.653 +                for nIter = 0, 6 do
   1.654 +                    local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
   1.655 +
   1.656 +                    function rectfresh:touch(event)
   1.657 +                        if event.phase == 'began' then
   1.658 +                            posMove = event.y
   1.659 +                            local nBase = event.y - (dsh - fontarial.height * 12)
   1.660 +                            local nRect = fontarial.height * 1.5
   1.661 +                            local nTemp = nBase / nRect
   1.662 +                            local nIdx  = 7 - math.floor(nTemp)
   1.663 +                            if dbIdx[nIdx] == 0 then
   1.664 +                                return
   1.665 +                            elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
   1.666 +                                event.target.color = color.lightGrey
   1.667 +                                dbMrk[nIdx] = 0
   1.668 +                            elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
   1.669 +                                event.target.color = {192, 192, 192}
   1.670 +                                dbMrk[nIdx] = 0
   1.671 +                            elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
   1.672 +                                event.target.color = {220, 210, 120}
   1.673 +                                dbMrk[nIdx] = dbIdx[nIdx]
   1.674 +                            else
   1.675 +                                event.target.color = color.khaki
   1.676 +                                dbMrk[nIdx] = dbIdx[nIdx]
   1.677 +                            end
   1.678 +                        end
   1.679 +                        if event.phase == 'ended' then
   1.680 +                            if math.abs(event.y - posMove) > fontarial.height*1.5 then
   1.681 +                                -- Provide callback to count rows in table
   1.682 +                                local nCount = 0
   1.683 +                                function countrows(udata, cols, values, names)
   1.684 +                                    assert(udata == 'dingdong')
   1.685 +                                    nCount = tonumber(values[1])
   1.686 +                                    return 0
   1.687 +                                end
   1.688 +                       
   1.689 +                                -- Repopulate UI conditionally
   1.690 +                                debe = sqlite3.open(pathStor .. 'amalog.sql')
   1.691 +                                local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
   1.692 +                                debe:close()
   1.693 +                                debe = nil
   1.694 +                       
   1.695 +                                if event.y - posMove > 0 then  -- Gesture upward
   1.696 +                                    if nScroll + 7 < nCount then
   1.697 +                                        nScroll = nScroll + 7
   1.698 +                                    else
   1.699 +                                        return
   1.700 +                                    end
   1.701 +                                else -- Gesture downward
   1.702 +                                    if nScroll - 7 >= 0 then
   1.703 +                                        nScroll = nScroll - 7
   1.704 +                                    else
   1.705 +                                        return
   1.706 +                                    end
   1.707 +                                end
   1.708 +                       
   1.709 +                                -- Kludge stucked event handlers
   1.710 +                                rectoddy:removeEventListener('touch', rectoddy)
   1.711 +                                recteven:removeEventListener('touch', recteven)
   1.712 +                                recthree:removeEventListener('touch', recthree)
   1.713 +                                rectfour:removeEventListener('touch', rectfour)
   1.714 +                                rectfive:removeEventListener('touch', rectfive)
   1.715 +                                rectseis:removeEventListener('touch', rectseis)
   1.716 +                                rectsieb:removeEventListener('touch', rectsieb)
   1.717 +
   1.718 +                                -- Clear viewport
   1.719 +                                for nIter = 0, 6 do
   1.720 +                                    local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
   1.721 +                       
   1.722 +                                    function rectfresh:touch(event)
   1.723 +                                        if event.phase == 'began' then
   1.724 +                                            posMove = event.y
   1.725 +                                            local nBase = event.y - (dsh - fontarial.height * 12)
   1.726 +                                            local nRect = fontarial.height * 1.5
   1.727 +                                            local nTemp = nBase / nRect
   1.728 +                                            local nIdx  = 7 - math.floor(nTemp)
   1.729 +                                            if dbIdx[nIdx] == 0 then
   1.730 +                                                return
   1.731 +                                            elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
   1.732 +                                                event.target.color = color.lightGrey
   1.733 +                                                dbMrk[nIdx] = 0
   1.734 +                                            elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
   1.735 +                                                event.target.color = {192, 192, 192}
   1.736 +                                                dbMrk[nIdx] = 0
   1.737 +                                            elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
   1.738 +                                                event.target.color = {220, 210, 120}
   1.739 +                                                dbMrk[nIdx] = dbIdx[nIdx]
   1.740 +                                            else
   1.741 +                                                event.target.color = color.khaki
   1.742 +                                                dbMrk[nIdx] = dbIdx[nIdx]
   1.743 +                                            end
   1.744 +                                        end
   1.745 +                                    end
   1.746 +                                    rectfresh:addEventListener('touch', rectfresh)
   1.747 +                       
   1.748 +                                    if nIter % 2 == 0 then
   1.749 +                                        rectfresh.color = color.lightGrey
   1.750 +                                    else
   1.751 +                                        rectfresh.color = {192, 192, 192}
   1.752 +                                    end
   1.753 +                       
   1.754 +                                    -- Clear indexes
   1.755 +                                    dbIdx[nIter+1] = 0
   1.756 +                                    dbMrk[nIter+1] = 0
   1.757 +                                end
   1.758 +                       
   1.759 +                                -- Redraw labels
   1.760 +                                local nIter = 6
   1.761 +                                --for nIter = 0, 7 do
   1.762 +                                local nTemp = nCount - nScroll
   1.763 +                                if nTemp < 7 then
   1.764 +                                    nIter = nTemp - 1
   1.765 +                                end
   1.766 +                       
   1.767 +                                debe = sqlite3.open(pathStor .. 'amalog.sql')
   1.768 +                                for dbRows in debe:nrows('SELECT * FROM qsos') do
   1.769 +                                    if nTemp < 8 then
   1.770 +                                        if nTemp < 0 then break end
   1.771 +                                        if nIter < 0 then break end
   1.772 +                                        local labrepop = director:createLabel({
   1.773 +                                            x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
   1.774 +                                            hAlignment='left', vAlignment='bottom',
   1.775 +                                            font=fontsegoe,
   1.776 +                                            text=dbRows['call']
   1.777 +                                        })
   1.778 +                                        dbIdx[nIter+1] = dbRows['id']
   1.779 +                                        nIter = nIter - 1
   1.780 +                                        nTemp = nTemp - 1
   1.781 +                                    else
   1.782 +                                        nTemp = nTemp - 1
   1.783 +                                    end
   1.784 +                                end
   1.785 +                                debe:close()
   1.786 +                                debe = nil
   1.787 +                            end
   1.788 +                            posMove = 0
   1.789 +                        end
   1.790 +                    end
   1.791 +                    rectfresh:addEventListener('touch', rectfresh)
   1.792 +
   1.793 +                    if nIter % 2 == 0 then
   1.794 +                        rectfresh.color = color.lightGrey
   1.795 +                    else
   1.796 +                        rectfresh.color = {192, 192, 192}
   1.797 +                    end
   1.798 +
   1.799 +                    -- Clear indexes
   1.800 +                    dbIdx[nIter+1] = 0
   1.801 +                    dbMrk[nIter+1] = 0
   1.802 +                end
   1.803 +
   1.804 +                -- Redraw labels
   1.805 +                local nIter = 6
   1.806 +                --for nIter = 0, 7 do
   1.807 +                local nTemp = nCount - nScroll
   1.808 +                if nTemp < 7 then
   1.809 +                    nIter = nTemp - 1
   1.810 +                end
   1.811 +
   1.812 +                debe = sqlite3.open(pathStor .. 'amalog.sql')
   1.813 +                for dbRows in debe:nrows('SELECT * FROM qsos') do
   1.814 +                    if nTemp < 8 then
   1.815 +                        if nTemp < 0 then break end
   1.816 +                        if nIter < 0 then break end
   1.817 +                        local labrepop = director:createLabel({
   1.818 +                            x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
   1.819 +                            hAlignment='left', vAlignment='bottom',
   1.820 +                            font=fontsegoe,
   1.821 +                            text=dbRows['call']
   1.822 +                        })
   1.823 +                        dbIdx[nIter+1] = dbRows['id']
   1.824 +                        nIter = nIter - 1
   1.825 +                        nTemp = nTemp - 1
   1.826 +                    else
   1.827 +                        nTemp = nTemp - 1
   1.828 +                    end
   1.829 +                end
   1.830 +                debe:close()
   1.831 +                debe = nil
   1.832 +            end
   1.833 +            posMove = 0
   1.834 +        end
   1.835 +    end
   1.836 +    recthree:addEventListener('touch', recthree)
   1.837 +
   1.838 +    function rectfour:touch(event)
   1.839 +        if event.phase == 'began' then
   1.840 +            posMove = event.y
   1.841 +            local nBase = event.y - (dsh - fontarial.height * 12)
   1.842 +            local nRect = fontarial.height * 1.5
   1.843 +            local nTemp = nBase / nRect
   1.844 +            local nIdx  = 7 - math.floor(nTemp)
   1.845 +            if dbIdx[nIdx] == 0 then
   1.846 +                return
   1.847 +            elseif rectfour.color.r == 220 and rectfour.color.g == 210 and rectfour.color.b == 120 then
   1.848 +                rectfour.color = {192, 192, 192}
   1.849 +                dbMrk[nIdx] = 0
   1.850 +            else
   1.851 +                rectfour.color = {220, 210, 120}
   1.852 +                dbMrk[nIdx] = dbIdx[nIdx]
   1.853 +            end
   1.854 +        end
   1.855 +
   1.856 +        if event.phase == 'ended' then
   1.857 +            if math.abs(event.y - posMove) > fontarial.height*1.5 then
   1.858 +                -- Provide callback to count rows in table
   1.859 +                local nCount = 0
   1.860 +                function countrows(udata, cols, values, names)
   1.861 +                    assert(udata == 'dingdong')
   1.862 +                    nCount = tonumber(values[1])
   1.863 +                    return 0
   1.864 +                end
   1.865 +
   1.866 +                -- Repopulate UI conditionally
   1.867 +                debe = sqlite3.open(pathStor .. 'amalog.sql')
   1.868 +                local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
   1.869 +                debe:close()
   1.870 +                debe = nil
   1.871 +
   1.872 +                if event.y - posMove > 0 then  -- Gesture upward
   1.873 +                    if nScroll + 7 < nCount then
   1.874 +                        nScroll = nScroll + 7
   1.875 +                    else
   1.876 +                        return
   1.877 +                    end
   1.878 +                else -- Gesture downward
   1.879 +                    if nScroll - 7 >= 0 then
   1.880 +                        nScroll = nScroll - 7
   1.881 +                    else
   1.882 +                        return
   1.883 +                    end
   1.884 +                end
   1.885 +
   1.886 +                -- Kludge stucked event handlers
   1.887 +                rectoddy:removeEventListener('touch', rectoddy)
   1.888 +                recteven:removeEventListener('touch', recteven)
   1.889 +                recthree:removeEventListener('touch', recthree)
   1.890 +                rectfour:removeEventListener('touch', rectfour)
   1.891 +                rectfive:removeEventListener('touch', rectfive)
   1.892 +                rectseis:removeEventListener('touch', rectseis)
   1.893 +                rectsieb:removeEventListener('touch', rectsieb)
   1.894 +
   1.895 +                -- Clear viewport
   1.896 +                for nIter = 0, 6 do
   1.897 +                    local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
   1.898 +
   1.899 +                    function rectfresh:touch(event)
   1.900 +                        if event.phase == 'began' then
   1.901 +                            posMove = event.y
   1.902 +                            local nBase = event.y - (dsh - fontarial.height * 12)
   1.903 +                            local nRect = fontarial.height * 1.5
   1.904 +                            local nTemp = nBase / nRect
   1.905 +                            local nIdx  = 7 - math.floor(nTemp)
   1.906 +                            if dbIdx[nIdx] == 0 then
   1.907 +                                return
   1.908 +                            elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
   1.909 +                                event.target.color = color.lightGrey
   1.910 +                                dbMrk[nIdx] = 0
   1.911 +                            elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
   1.912 +                                event.target.color = {192, 192, 192}
   1.913 +                                dbMrk[nIdx] = 0
   1.914 +                            elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
   1.915 +                                event.target.color = {220, 210, 120}
   1.916 +                                dbMrk[nIdx] = dbIdx[nIdx]
   1.917 +                            else
   1.918 +                                event.target.color = color.khaki
   1.919 +                                dbMrk[nIdx] = dbIdx[nIdx]
   1.920 +                            end
   1.921 +                        end
   1.922 +                        if event.phase == 'ended' then
   1.923 +                            if math.abs(event.y - posMove) > fontarial.height*1.5 then
   1.924 +                                -- Provide callback to count rows in table
   1.925 +                                local nCount = 0
   1.926 +                                function countrows(udata, cols, values, names)
   1.927 +                                    assert(udata == 'dingdong')
   1.928 +                                    nCount = tonumber(values[1])
   1.929 +                                    return 0
   1.930 +                                end
   1.931 +                       
   1.932 +                                -- Repopulate UI conditionally
   1.933 +                                debe = sqlite3.open(pathStor .. 'amalog.sql')
   1.934 +                                local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
   1.935 +                                debe:close()
   1.936 +                                debe = nil
   1.937 +                       
   1.938 +                                if event.y - posMove > 0 then  -- Gesture upward
   1.939 +                                    if nScroll + 7 < nCount then
   1.940 +                                        nScroll = nScroll + 7
   1.941 +                                    else
   1.942 +                                        return
   1.943 +                                    end
   1.944 +                                else -- Gesture downward
   1.945 +                                    if nScroll - 7 >= 0 then
   1.946 +                                        nScroll = nScroll - 7
   1.947 +                                    else
   1.948 +                                        return
   1.949 +                                    end
   1.950 +                                end
   1.951 +                       
   1.952 +                                -- Kludge stucked event handlers
   1.953 +                                rectoddy:removeEventListener('touch', rectoddy)
   1.954 +                                recteven:removeEventListener('touch', recteven)
   1.955 +                                recthree:removeEventListener('touch', recthree)
   1.956 +                                rectfour:removeEventListener('touch', rectfour)
   1.957 +                                rectfive:removeEventListener('touch', rectfive)
   1.958 +                                rectseis:removeEventListener('touch', rectseis)
   1.959 +                                rectsieb:removeEventListener('touch', rectsieb)
   1.960 +
   1.961 +                                -- Clear viewport
   1.962 +                                for nIter = 0, 6 do
   1.963 +                                    local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
   1.964 +                       
   1.965 +                                    function rectfresh:touch(event)
   1.966 +                                        if event.phase == 'began' then
   1.967 +                                            posMove = event.y
   1.968 +                                            local nBase = event.y - (dsh - fontarial.height * 12)
   1.969 +                                            local nRect = fontarial.height * 1.5
   1.970 +                                            local nTemp = nBase / nRect
   1.971 +                                            local nIdx  = 7 - math.floor(nTemp)
   1.972 +                                            if dbIdx[nIdx] == 0 then
   1.973 +                                                return
   1.974 +                                            elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
   1.975 +                                                event.target.color = color.lightGrey
   1.976 +                                                dbMrk[nIdx] = 0
   1.977 +                                            elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
   1.978 +                                                event.target.color = {192, 192, 192}
   1.979 +                                                dbMrk[nIdx] = 0
   1.980 +                                            elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
   1.981 +                                                event.target.color = {220, 210, 120}
   1.982 +                                                dbMrk[nIdx] = dbIdx[nIdx]
   1.983 +                                            else
   1.984 +                                                event.target.color = color.khaki
   1.985 +                                                dbMrk[nIdx] = dbIdx[nIdx]
   1.986 +                                            end
   1.987 +                                        end
   1.988 +                                    end
   1.989 +                                    rectfresh:addEventListener('touch', rectfresh)
   1.990 +                       
   1.991 +                                    if nIter % 2 == 0 then
   1.992 +                                        rectfresh.color = color.lightGrey
   1.993 +                                    else
   1.994 +                                        rectfresh.color = {192, 192, 192}
   1.995 +                                    end
   1.996 +                       
   1.997 +                                    -- Clear indexes
   1.998 +                                    dbIdx[nIter+1] = 0
   1.999 +                                    dbMrk[nIter+1] = 0
  1.1000 +                                end
  1.1001 +                       
  1.1002 +                                -- Redraw labels
  1.1003 +                                local nIter = 6
  1.1004 +                                --for nIter = 0, 7 do
  1.1005 +                                local nTemp = nCount - nScroll
  1.1006 +                                if nTemp < 7 then
  1.1007 +                                    nIter = nTemp - 1
  1.1008 +                                end
  1.1009 +                       
  1.1010 +                                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.1011 +                                for dbRows in debe:nrows('SELECT * FROM qsos') do
  1.1012 +                                    if nTemp < 8 then
  1.1013 +                                        if nTemp < 0 then break end
  1.1014 +                                        if nIter < 0 then break end
  1.1015 +                                        local labrepop = director:createLabel({
  1.1016 +                                            x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
  1.1017 +                                            hAlignment='left', vAlignment='bottom',
  1.1018 +                                            font=fontsegoe,
  1.1019 +                                            text=dbRows['call']
  1.1020 +                                        })
  1.1021 +                                        dbIdx[nIter+1] = dbRows['id']
  1.1022 +                                        nIter = nIter - 1
  1.1023 +                                        nTemp = nTemp - 1
  1.1024 +                                    else
  1.1025 +                                        nTemp = nTemp - 1
  1.1026 +                                    end
  1.1027 +                                end
  1.1028 +                                debe:close()
  1.1029 +                                debe = nil
  1.1030 +                            end
  1.1031 +                            posMove = 0
  1.1032 +                        end
  1.1033 +                    end
  1.1034 +                    rectfresh:addEventListener('touch', rectfresh)
  1.1035 +
  1.1036 +                    if nIter % 2 == 0 then
  1.1037 +                        rectfresh.color = color.lightGrey
  1.1038 +                    else
  1.1039 +                        rectfresh.color = {192, 192, 192}
  1.1040 +                    end
  1.1041 +
  1.1042 +                    -- Clear indexes
  1.1043 +                    dbIdx[nIter+1] = 0
  1.1044 +                    dbMrk[nIter+1] = 0
  1.1045 +                end
  1.1046 +
  1.1047 +                -- Redraw labels
  1.1048 +                local nIter = 6
  1.1049 +                --for nIter = 0, 7 do
  1.1050 +                local nTemp = nCount - nScroll
  1.1051 +                if nTemp < 7 then
  1.1052 +                    nIter = nTemp - 1
  1.1053 +                end
  1.1054 +
  1.1055 +                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.1056 +                for dbRows in debe:nrows('SELECT * FROM qsos') do
  1.1057 +                    if nTemp < 8 then
  1.1058 +                        if nTemp < 0 then break end
  1.1059 +                        if nIter < 0 then break end
  1.1060 +                        local labrepop = director:createLabel({
  1.1061 +                            x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
  1.1062 +                            hAlignment='left', vAlignment='bottom',
  1.1063 +                            font=fontsegoe,
  1.1064 +                            text=dbRows['call']
  1.1065 +                        })
  1.1066 +                        dbIdx[nIter+1] = dbRows['id']
  1.1067 +                        nIter = nIter - 1
  1.1068 +                        nTemp = nTemp - 1
  1.1069 +                    else
  1.1070 +                        nTemp = nTemp - 1
  1.1071 +                    end
  1.1072 +                end
  1.1073 +                debe:close()
  1.1074 +                debe = nil
  1.1075 +            end
  1.1076 +            posMove = 0
  1.1077 +        end
  1.1078 +    end
  1.1079 +    rectfour:addEventListener('touch', rectfour)
  1.1080 +
  1.1081 +    function rectfive:touch(event)
  1.1082 +        if event.phase == 'began' then
  1.1083 +            posMove = event.y
  1.1084 +            local nBase = event.y - (dsh - fontarial.height * 12)
  1.1085 +            local nRect = fontarial.height * 1.5
  1.1086 +            local nTemp = nBase / nRect
  1.1087 +            local nIdx  = 7 - math.floor(nTemp)
  1.1088 +            if dbIdx[nIdx] == 0 then
  1.1089 +                return
  1.1090 +            elseif rectfive.color.r == 240 and rectfive.color.g == 230 and rectfive.color.b == 140 then
  1.1091 +                rectfive.color = color.lightGrey
  1.1092 +                dbMrk[nIdx] = 0
  1.1093 +            else
  1.1094 +                rectfive.color = color.khaki
  1.1095 +                dbMrk[nIdx] = dbIdx[nIdx]
  1.1096 +            end
  1.1097 +        end
  1.1098 +
  1.1099 +        if event.phase == 'ended' then
  1.1100 +            if math.abs(event.y - posMove) > fontarial.height*1.5 then
  1.1101 +                -- Provide callback to count rows in table
  1.1102 +                local nCount = 0
  1.1103 +                function countrows(udata, cols, values, names)
  1.1104 +                    assert(udata == 'dingdong')
  1.1105 +                    nCount = tonumber(values[1])
  1.1106 +                    return 0
  1.1107 +                end
  1.1108 +
  1.1109 +                -- Repopulate UI conditionally
  1.1110 +                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.1111 +                local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
  1.1112 +                debe:close()
  1.1113 +                debe = nil
  1.1114 +
  1.1115 +                if event.y - posMove > 0 then  -- Gesture upward
  1.1116 +                    if nScroll + 7 < nCount then
  1.1117 +                        nScroll = nScroll + 7
  1.1118 +                    else
  1.1119 +                        return
  1.1120 +                    end
  1.1121 +                else -- Gesture downward
  1.1122 +                    if nScroll - 7 >= 0 then
  1.1123 +                        nScroll = nScroll - 7
  1.1124 +                    else
  1.1125 +                        return
  1.1126 +                    end
  1.1127 +                end
  1.1128 +
  1.1129 +                -- Kludge stucked event handlers
  1.1130 +                rectoddy:removeEventListener('touch', rectoddy)
  1.1131 +                recteven:removeEventListener('touch', recteven)
  1.1132 +                recthree:removeEventListener('touch', recthree)
  1.1133 +                rectfour:removeEventListener('touch', rectfour)
  1.1134 +                rectfive:removeEventListener('touch', rectfive)
  1.1135 +                rectseis:removeEventListener('touch', rectseis)
  1.1136 +                rectsieb:removeEventListener('touch', rectsieb)
  1.1137 +
  1.1138 +                -- Clear viewport
  1.1139 +                for nIter = 0, 6 do
  1.1140 +                    local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
  1.1141 +
  1.1142 +                    function rectfresh:touch(event)
  1.1143 +                        if event.phase == 'began' then
  1.1144 +                            posMove = event.y
  1.1145 +                            local nBase = event.y - (dsh - fontarial.height * 12)
  1.1146 +                            local nRect = fontarial.height * 1.5
  1.1147 +                            local nTemp = nBase / nRect
  1.1148 +                            local nIdx  = 7 - math.floor(nTemp)
  1.1149 +                            if dbIdx[nIdx] == 0 then
  1.1150 +                                return
  1.1151 +                            elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
  1.1152 +                                event.target.color = color.lightGrey
  1.1153 +                                dbMrk[nIdx] = 0
  1.1154 +                            elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
  1.1155 +                                event.target.color = {192, 192, 192}
  1.1156 +                                dbMrk[nIdx] = 0
  1.1157 +                            elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
  1.1158 +                                event.target.color = {220, 210, 120}
  1.1159 +                                dbMrk[nIdx] = dbIdx[nIdx]
  1.1160 +                            else
  1.1161 +                                event.target.color = color.khaki
  1.1162 +                                dbMrk[nIdx] = dbIdx[nIdx]
  1.1163 +                            end
  1.1164 +                        end
  1.1165 +                        if event.phase == 'ended' then
  1.1166 +                            if math.abs(event.y - posMove) > fontarial.height*1.5 then
  1.1167 +                                -- Provide callback to count rows in table
  1.1168 +                                local nCount = 0
  1.1169 +                                function countrows(udata, cols, values, names)
  1.1170 +                                    assert(udata == 'dingdong')
  1.1171 +                                    nCount = tonumber(values[1])
  1.1172 +                                    return 0
  1.1173 +                                end
  1.1174 +                       
  1.1175 +                                -- Repopulate UI conditionally
  1.1176 +                                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.1177 +                                local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
  1.1178 +                                debe:close()
  1.1179 +                                debe = nil
  1.1180 +                       
  1.1181 +                                if event.y - posMove > 0 then  -- Gesture upward
  1.1182 +                                    if nScroll + 7 < nCount then
  1.1183 +                                        nScroll = nScroll + 7
  1.1184 +                                    else
  1.1185 +                                        return
  1.1186 +                                    end
  1.1187 +                                else -- Gesture downward
  1.1188 +                                    if nScroll - 7 >= 0 then
  1.1189 +                                        nScroll = nScroll - 7
  1.1190 +                                    else
  1.1191 +                                        return
  1.1192 +                                    end
  1.1193 +                                end
  1.1194 +                       
  1.1195 +                                -- Kludge stucked event handlers
  1.1196 +                                rectoddy:removeEventListener('touch', rectoddy)
  1.1197 +                                recteven:removeEventListener('touch', recteven)
  1.1198 +                                recthree:removeEventListener('touch', recthree)
  1.1199 +                                rectfour:removeEventListener('touch', rectfour)
  1.1200 +                                rectfive:removeEventListener('touch', rectfive)
  1.1201 +                                rectseis:removeEventListener('touch', rectseis)
  1.1202 +                                rectsieb:removeEventListener('touch', rectsieb)
  1.1203 +
  1.1204 +                                -- Clear viewport
  1.1205 +                                for nIter = 0, 6 do
  1.1206 +                                    local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
  1.1207 +                       
  1.1208 +                                    function rectfresh:touch(event)
  1.1209 +                                        if event.phase == 'began' then
  1.1210 +                                            posMove = event.y
  1.1211 +                                            local nBase = event.y - (dsh - fontarial.height * 12)
  1.1212 +                                            local nRect = fontarial.height * 1.5
  1.1213 +                                            local nTemp = nBase / nRect
  1.1214 +                                            local nIdx  = 7 - math.floor(nTemp)
  1.1215 +                                            if dbIdx[nIdx] == 0 then
  1.1216 +                                                return
  1.1217 +                                            elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
  1.1218 +                                                event.target.color = color.lightGrey
  1.1219 +                                                dbMrk[nIdx] = 0
  1.1220 +                                            elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
  1.1221 +                                                event.target.color = {192, 192, 192}
  1.1222 +                                                dbMrk[nIdx] = 0
  1.1223 +                                            elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
  1.1224 +                                                event.target.color = {220, 210, 120}
  1.1225 +                                                dbMrk[nIdx] = dbIdx[nIdx]
  1.1226 +                                            else
  1.1227 +                                                event.target.color = color.khaki
  1.1228 +                                                dbMrk[nIdx] = dbIdx[nIdx]
  1.1229 +                                            end
  1.1230 +                                        end
  1.1231 +                                    end
  1.1232 +                                    rectfresh:addEventListener('touch', rectfresh)
  1.1233 +                       
  1.1234 +                                    if nIter % 2 == 0 then
  1.1235 +                                        rectfresh.color = color.lightGrey
  1.1236 +                                    else
  1.1237 +                                        rectfresh.color = {192, 192, 192}
  1.1238 +                                    end
  1.1239 +                       
  1.1240 +                                    -- Clear indexes
  1.1241 +                                    dbIdx[nIter+1] = 0
  1.1242 +                                    dbMrk[nIter+1] = 0
  1.1243 +                                end
  1.1244 +                       
  1.1245 +                                -- Redraw labels
  1.1246 +                                local nIter = 6
  1.1247 +                                --for nIter = 0, 7 do
  1.1248 +                                local nTemp = nCount - nScroll
  1.1249 +                                if nTemp < 7 then
  1.1250 +                                    nIter = nTemp - 1
  1.1251 +                                end
  1.1252 +                       
  1.1253 +                                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.1254 +                                for dbRows in debe:nrows('SELECT * FROM qsos') do
  1.1255 +                                    if nTemp < 8 then
  1.1256 +                                        if nTemp < 0 then break end
  1.1257 +                                        if nIter < 0 then break end
  1.1258 +                                        local labrepop = director:createLabel({
  1.1259 +                                            x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
  1.1260 +                                            hAlignment='left', vAlignment='bottom',
  1.1261 +                                            font=fontsegoe,
  1.1262 +                                            text=dbRows['call']
  1.1263 +                                        })
  1.1264 +                                        dbIdx[nIter+1] = dbRows['id']
  1.1265 +                                        nIter = nIter - 1
  1.1266 +                                        nTemp = nTemp - 1
  1.1267 +                                    else
  1.1268 +                                        nTemp = nTemp - 1
  1.1269 +                                    end
  1.1270 +                                end
  1.1271 +                                debe:close()
  1.1272 +                                debe = nil
  1.1273 +                            end
  1.1274 +                            posMove = 0
  1.1275 +                        end
  1.1276 +                    end
  1.1277 +                    rectfresh:addEventListener('touch', rectfresh)
  1.1278 +
  1.1279 +                    if nIter % 2 == 0 then
  1.1280 +                        rectfresh.color = color.lightGrey
  1.1281 +                    else
  1.1282 +                        rectfresh.color = {192, 192, 192}
  1.1283 +                    end
  1.1284 +
  1.1285 +                    -- Clear indexes
  1.1286 +                    dbIdx[nIter+1] = 0
  1.1287 +                    dbMrk[nIter+1] = 0
  1.1288 +                end
  1.1289 +
  1.1290 +                -- Redraw labels
  1.1291 +                local nIter = 6
  1.1292 +                --for nIter = 0, 7 do
  1.1293 +                local nTemp = nCount - nScroll
  1.1294 +                if nTemp < 7 then
  1.1295 +                    nIter = nTemp - 1
  1.1296 +                end
  1.1297 +
  1.1298 +                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.1299 +                for dbRows in debe:nrows('SELECT * FROM qsos') do
  1.1300 +                    if nTemp < 8 then
  1.1301 +                        if nTemp < 0 then break end
  1.1302 +                        if nIter < 0 then break end
  1.1303 +                        local labrepop = director:createLabel({
  1.1304 +                            x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
  1.1305 +                            hAlignment='left', vAlignment='bottom',
  1.1306 +                            font=fontsegoe,
  1.1307 +                            text=dbRows['call']
  1.1308 +                        })
  1.1309 +                        dbIdx[nIter+1] = dbRows['id']
  1.1310 +                        nIter = nIter - 1
  1.1311 +                        nTemp = nTemp - 1
  1.1312 +                    else
  1.1313 +                        nTemp = nTemp - 1
  1.1314 +                    end
  1.1315 +                end
  1.1316 +                debe:close()
  1.1317 +                debe = nil
  1.1318 +            end
  1.1319 +            posMove = 0
  1.1320 +        end
  1.1321 +    end
  1.1322 +    rectfive:addEventListener('touch', rectfive)
  1.1323 +
  1.1324 +    function rectseis:touch(event)
  1.1325 +        if event.phase == 'began' then
  1.1326 +            posMove = event.y
  1.1327 +            local nBase = event.y - (dsh - fontarial.height * 12)
  1.1328 +            local nRect = fontarial.height * 1.5
  1.1329 +            local nTemp = nBase / nRect
  1.1330 +            local nIdx  = 7 - math.floor(nTemp)
  1.1331 +            if dbIdx[nIdx] == 0 then
  1.1332 +                return
  1.1333 +            elseif rectseis.color.r == 220 and rectseis.color.g == 210 and rectseis.color.b == 120 then
  1.1334 +                rectseis.color = {192, 192, 192}
  1.1335 +                dbMrk[nIdx] = 0
  1.1336 +            else
  1.1337 +                rectseis.color = {220, 210, 120}
  1.1338 +                dbMrk[nIdx] = dbIdx[nIdx]
  1.1339 +            end
  1.1340 +        end
  1.1341 +
  1.1342 +        if event.phase == 'ended' then
  1.1343 +            if math.abs(event.y - posMove) > fontarial.height*1.5 then
  1.1344 +                -- Provide callback to count rows in table
  1.1345 +                local nCount = 0
  1.1346 +                function countrows(udata, cols, values, names)
  1.1347 +                    assert(udata == 'dingdong')
  1.1348 +                    nCount = tonumber(values[1])
  1.1349 +                    return 0
  1.1350 +                end
  1.1351 +
  1.1352 +                -- Repopulate UI conditionally
  1.1353 +                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.1354 +                local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
  1.1355 +                debe:close()
  1.1356 +                debe = nil
  1.1357 +
  1.1358 +                if event.y - posMove > 0 then  -- Gesture upward
  1.1359 +                    if nScroll + 7 < nCount then
  1.1360 +                        nScroll = nScroll + 7
  1.1361 +                    else
  1.1362 +                        return
  1.1363 +                    end
  1.1364 +                else -- Gesture downward
  1.1365 +                    if nScroll - 7 >= 0 then
  1.1366 +                        nScroll = nScroll - 7
  1.1367 +                    else
  1.1368 +                        return
  1.1369 +                    end
  1.1370 +                end
  1.1371 +
  1.1372 +                -- Kludge stucked event handlers
  1.1373 +                rectoddy:removeEventListener('touch', rectoddy)
  1.1374 +                recteven:removeEventListener('touch', recteven)
  1.1375 +                recthree:removeEventListener('touch', recthree)
  1.1376 +                rectfour:removeEventListener('touch', rectfour)
  1.1377 +                rectfive:removeEventListener('touch', rectfive)
  1.1378 +                rectseis:removeEventListener('touch', rectseis)
  1.1379 +                rectsieb:removeEventListener('touch', rectsieb)
  1.1380 +
  1.1381 +                -- Clear viewport
  1.1382 +                for nIter = 0, 6 do
  1.1383 +                    local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
  1.1384 +
  1.1385 +                    function rectfresh:touch(event)
  1.1386 +                        if event.phase == 'began' then
  1.1387 +                            posMove = event.y
  1.1388 +                            local nBase = event.y - (dsh - fontarial.height * 12)
  1.1389 +                            local nRect = fontarial.height * 1.5
  1.1390 +                            local nTemp = nBase / nRect
  1.1391 +                            local nIdx  = 7 - math.floor(nTemp)
  1.1392 +                            if dbIdx[nIdx] == 0 then
  1.1393 +                                return
  1.1394 +                            elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
  1.1395 +                                event.target.color = color.lightGrey
  1.1396 +                                dbMrk[nIdx] = 0
  1.1397 +                            elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
  1.1398 +                                event.target.color = {192, 192, 192}
  1.1399 +                                dbMrk[nIdx] = 0
  1.1400 +                            elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
  1.1401 +                                event.target.color = {220, 210, 120}
  1.1402 +                                dbMrk[nIdx] = dbIdx[nIdx]
  1.1403 +                            else
  1.1404 +                                event.target.color = color.khaki
  1.1405 +                                dbMrk[nIdx] = dbIdx[nIdx]
  1.1406 +                            end
  1.1407 +                        end
  1.1408 +                        if event.phase == 'ended' then
  1.1409 +                            if math.abs(event.y - posMove) > fontarial.height*1.5 then
  1.1410 +                                -- Provide callback to count rows in table
  1.1411 +                                local nCount = 0
  1.1412 +                                function countrows(udata, cols, values, names)
  1.1413 +                                    assert(udata == 'dingdong')
  1.1414 +                                    nCount = tonumber(values[1])
  1.1415 +                                    return 0
  1.1416 +                                end
  1.1417 +                       
  1.1418 +                                -- Repopulate UI conditionally
  1.1419 +                                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.1420 +                                local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
  1.1421 +                                debe:close()
  1.1422 +                                debe = nil
  1.1423 +                       
  1.1424 +                                if event.y - posMove > 0 then  -- Gesture upward
  1.1425 +                                    if nScroll + 7 < nCount then
  1.1426 +                                        nScroll = nScroll + 7
  1.1427 +                                    else
  1.1428 +                                        return
  1.1429 +                                    end
  1.1430 +                                else -- Gesture downward
  1.1431 +                                    if nScroll - 7 >= 0 then
  1.1432 +                                        nScroll = nScroll - 7
  1.1433 +                                    else
  1.1434 +                                        return
  1.1435 +                                    end
  1.1436 +                                end
  1.1437 +                       
  1.1438 +                                -- Kludge stucked event handlers
  1.1439 +                                rectoddy:removeEventListener('touch', rectoddy)
  1.1440 +                                recteven:removeEventListener('touch', recteven)
  1.1441 +                                recthree:removeEventListener('touch', recthree)
  1.1442 +                                rectfour:removeEventListener('touch', rectfour)
  1.1443 +                                rectfive:removeEventListener('touch', rectfive)
  1.1444 +                                rectseis:removeEventListener('touch', rectseis)
  1.1445 +                                rectsieb:removeEventListener('touch', rectsieb)
  1.1446 +
  1.1447 +                                -- Clear viewport
  1.1448 +                                for nIter = 0, 6 do
  1.1449 +                                    local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
  1.1450 +                       
  1.1451 +                                    function rectfresh:touch(event)
  1.1452 +                                        if event.phase == 'began' then
  1.1453 +                                            posMove = event.y
  1.1454 +                                            local nBase = event.y - (dsh - fontarial.height * 12)
  1.1455 +                                            local nRect = fontarial.height * 1.5
  1.1456 +                                            local nTemp = nBase / nRect
  1.1457 +                                            local nIdx  = 7 - math.floor(nTemp)
  1.1458 +                                            if dbIdx[nIdx] == 0 then
  1.1459 +                                                return
  1.1460 +                                            elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
  1.1461 +                                                event.target.color = color.lightGrey
  1.1462 +                                                dbMrk[nIdx] = 0
  1.1463 +                                            elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
  1.1464 +                                                event.target.color = {192, 192, 192}
  1.1465 +                                                dbMrk[nIdx] = 0
  1.1466 +                                            elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
  1.1467 +                                                event.target.color = {220, 210, 120}
  1.1468 +                                                dbMrk[nIdx] = dbIdx[nIdx]
  1.1469 +                                            else
  1.1470 +                                                event.target.color = color.khaki
  1.1471 +                                                dbMrk[nIdx] = dbIdx[nIdx]
  1.1472 +                                            end
  1.1473 +                                        end
  1.1474 +                                    end
  1.1475 +                                    rectfresh:addEventListener('touch', rectfresh)
  1.1476 +                       
  1.1477 +                                    if nIter % 2 == 0 then
  1.1478 +                                        rectfresh.color = color.lightGrey
  1.1479 +                                    else
  1.1480 +                                        rectfresh.color = {192, 192, 192}
  1.1481 +                                    end
  1.1482 +                       
  1.1483 +                                    -- Clear indexes
  1.1484 +                                    dbIdx[nIter+1] = 0
  1.1485 +                                    dbMrk[nIter+1] = 0
  1.1486 +                                end
  1.1487 +                       
  1.1488 +                                -- Redraw labels
  1.1489 +                                local nIter = 6
  1.1490 +                                --for nIter = 0, 7 do
  1.1491 +                                local nTemp = nCount - nScroll
  1.1492 +                                if nTemp < 7 then
  1.1493 +                                    nIter = nTemp - 1
  1.1494 +                                end
  1.1495 +                       
  1.1496 +                                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.1497 +                                for dbRows in debe:nrows('SELECT * FROM qsos') do
  1.1498 +                                    if nTemp < 8 then
  1.1499 +                                        if nTemp < 0 then break end
  1.1500 +                                        if nIter < 0 then break end
  1.1501 +                                        local labrepop = director:createLabel({
  1.1502 +                                            x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
  1.1503 +                                            hAlignment='left', vAlignment='bottom',
  1.1504 +                                            font=fontsegoe,
  1.1505 +                                            text=dbRows['call']
  1.1506 +                                        })
  1.1507 +                                        dbIdx[nIter+1] = dbRows['id']
  1.1508 +                                        nIter = nIter - 1
  1.1509 +                                        nTemp = nTemp - 1
  1.1510 +                                    else
  1.1511 +                                        nTemp = nTemp - 1
  1.1512 +                                    end
  1.1513 +                                end
  1.1514 +                                debe:close()
  1.1515 +                                debe = nil
  1.1516 +                            end
  1.1517 +                            posMove = 0
  1.1518 +                        end
  1.1519 +                    end
  1.1520 +                    rectfresh:addEventListener('touch', rectfresh)
  1.1521 +
  1.1522 +                    if nIter % 2 == 0 then
  1.1523 +                        rectfresh.color = color.lightGrey
  1.1524 +                    else
  1.1525 +                        rectfresh.color = {192, 192, 192}
  1.1526 +                    end
  1.1527 +
  1.1528 +                    -- Clear indexes
  1.1529 +                    dbIdx[nIter+1] = 0
  1.1530 +                    dbMrk[nIter+1] = 0
  1.1531 +                end
  1.1532 +
  1.1533 +                -- Redraw labels
  1.1534 +                local nIter = 6
  1.1535 +                --for nIter = 0, 7 do
  1.1536 +                local nTemp = nCount - nScroll
  1.1537 +                if nTemp < 7 then
  1.1538 +                    nIter = nTemp - 1
  1.1539 +                end
  1.1540 +
  1.1541 +                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.1542 +                for dbRows in debe:nrows('SELECT * FROM qsos') do
  1.1543 +                    if nTemp < 8 then
  1.1544 +                        if nTemp < 0 then break end
  1.1545 +                        if nIter < 0 then break end
  1.1546 +                        local labrepop = director:createLabel({
  1.1547 +                            x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
  1.1548 +                            hAlignment='left', vAlignment='bottom',
  1.1549 +                            font=fontsegoe,
  1.1550 +                            text=dbRows['call']
  1.1551 +                        })
  1.1552 +                        dbIdx[nIter+1] = dbRows['id']
  1.1553 +                        nIter = nIter - 1
  1.1554 +                        nTemp = nTemp - 1
  1.1555 +                    else
  1.1556 +                        nTemp = nTemp - 1
  1.1557 +                    end
  1.1558 +                end
  1.1559 +                debe:close()
  1.1560 +                debe = nil
  1.1561 +            end
  1.1562 +            posMove = 0
  1.1563 +        end
  1.1564 +    end
  1.1565 +    rectseis:addEventListener('touch', rectseis)
  1.1566 +
  1.1567 +    function rectsieb:touch(event)
  1.1568 +        if event.phase == 'began' then
  1.1569 +            posMove = event.y
  1.1570 +            local nBase = event.y - (dsh - fontarial.height * 12)
  1.1571 +            local nRect = fontarial.height * 1.5
  1.1572 +            local nTemp = nBase / nRect
  1.1573 +            local nIdx  = 7 - math.floor(nTemp)
  1.1574 +            if dbIdx[nIdx] == 0 then
  1.1575 +                return
  1.1576 +            elseif rectsieb.color.r == 240 and rectsieb.color.g == 230 and rectsieb.color.b == 140 then
  1.1577 +                rectsieb.color = color.lightGrey
  1.1578 +                dbMrk[nIdx] = 0
  1.1579 +            else
  1.1580 +                rectsieb.color = color.khaki
  1.1581 +                dbMrk[nIdx] = dbIdx[nIdx]
  1.1582 +            end
  1.1583 +        end
  1.1584 +
  1.1585 +        if event.phase == 'ended' then
  1.1586 +            if math.abs(event.y - posMove) > fontarial.height*1.5 then
  1.1587 +                -- Provide callback to count rows in table
  1.1588 +                local nCount = 0
  1.1589 +                function countrows(udata, cols, values, names)
  1.1590 +                    assert(udata == 'dingdong')
  1.1591 +                    nCount = tonumber(values[1])
  1.1592 +                    return 0
  1.1593 +                end
  1.1594 +
  1.1595 +                -- Repopulate UI conditionally
  1.1596 +                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.1597 +                local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
  1.1598 +                debe:close()
  1.1599 +                debe = nil
  1.1600 +
  1.1601 +                if event.y - posMove > 0 then  -- Gesture upward
  1.1602 +                    if nScroll + 7 < nCount then
  1.1603 +                        nScroll = nScroll + 7
  1.1604 +                    else
  1.1605 +                        return
  1.1606 +                    end
  1.1607 +                else -- Gesture downward
  1.1608 +                    if nScroll - 7 >= 0 then
  1.1609 +                        nScroll = nScroll - 7
  1.1610 +                    else
  1.1611 +                        return
  1.1612 +                    end
  1.1613 +                end
  1.1614 +
  1.1615 +                -- Kludge stucked event handlers
  1.1616 +                rectoddy:removeEventListener('touch', rectoddy)
  1.1617 +                recteven:removeEventListener('touch', recteven)
  1.1618 +                recthree:removeEventListener('touch', recthree)
  1.1619 +                rectfour:removeEventListener('touch', rectfour)
  1.1620 +                rectfive:removeEventListener('touch', rectfive)
  1.1621 +                rectseis:removeEventListener('touch', rectseis)
  1.1622 +                rectsieb:removeEventListener('touch', rectsieb)
  1.1623 +
  1.1624 +                -- Clear viewport
  1.1625 +                for nIter = 0, 6 do
  1.1626 +                    local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
  1.1627 +
  1.1628 +                    function rectfresh:touch(event)
  1.1629 +                        if event.phase == 'began' then
  1.1630 +                            posMove = event.y
  1.1631 +                            local nBase = event.y - (dsh - fontarial.height * 12)
  1.1632 +                            local nRect = fontarial.height * 1.5
  1.1633 +                            local nTemp = nBase / nRect
  1.1634 +                            local nIdx  = 7 - math.floor(nTemp)
  1.1635 +                            if dbIdx[nIdx] == 0 then
  1.1636 +                                return
  1.1637 +                            elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
  1.1638 +                                event.target.color = color.lightGrey
  1.1639 +                                dbMrk[nIdx] = 0
  1.1640 +                            elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
  1.1641 +                                event.target.color = {192, 192, 192}
  1.1642 +                                dbMrk[nIdx] = 0
  1.1643 +                            elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
  1.1644 +                                event.target.color = {220, 210, 120}
  1.1645 +                                dbMrk[nIdx] = dbIdx[nIdx]
  1.1646 +                            else
  1.1647 +                                event.target.color = color.khaki
  1.1648 +                                dbMrk[nIdx] = dbIdx[nIdx]
  1.1649 +                            end
  1.1650 +                        end
  1.1651 +                        if event.phase == 'ended' then
  1.1652 +                            if math.abs(event.y - posMove) > fontarial.height*1.5 then
  1.1653 +                                -- Provide callback to count rows in table
  1.1654 +                                local nCount = 0
  1.1655 +                                function countrows(udata, cols, values, names)
  1.1656 +                                    assert(udata == 'dingdong')
  1.1657 +                                    nCount = tonumber(values[1])
  1.1658 +                                    return 0
  1.1659 +                                end
  1.1660 +                       
  1.1661 +                                -- Repopulate UI conditionally
  1.1662 +                                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.1663 +                                local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
  1.1664 +                                debe:close()
  1.1665 +                                debe = nil
  1.1666 +                       
  1.1667 +                                if event.y - posMove > 0 then  -- Gesture upward
  1.1668 +                                    if nScroll + 7 < nCount then
  1.1669 +                                        nScroll = nScroll + 7
  1.1670 +                                    else
  1.1671 +                                        return
  1.1672 +                                    end
  1.1673 +                                else -- Gesture downward
  1.1674 +                                    if nScroll - 7 >= 0 then
  1.1675 +                                        nScroll = nScroll - 7
  1.1676 +                                    else
  1.1677 +                                        return
  1.1678 +                                    end
  1.1679 +                                end
  1.1680 +                       
  1.1681 +                                -- Kludge stucked event handlers
  1.1682 +                                rectoddy:removeEventListener('touch', rectoddy)
  1.1683 +                                recteven:removeEventListener('touch', recteven)
  1.1684 +                                recthree:removeEventListener('touch', recthree)
  1.1685 +                                rectfour:removeEventListener('touch', rectfour)
  1.1686 +                                rectfive:removeEventListener('touch', rectfive)
  1.1687 +                                rectseis:removeEventListener('touch', rectseis)
  1.1688 +                                rectsieb:removeEventListener('touch', rectsieb)
  1.1689 +
  1.1690 +                                -- Clear viewport
  1.1691 +                                for nIter = 0, 6 do
  1.1692 +                                    local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
  1.1693 +                       
  1.1694 +                                    function rectfresh:touch(event)
  1.1695 +                                        if event.phase == 'began' then
  1.1696 +                                            posMove = event.y
  1.1697 +                                            local nBase = event.y - (dsh - fontarial.height * 12)
  1.1698 +                                            local nRect = fontarial.height * 1.5
  1.1699 +                                            local nTemp = nBase / nRect
  1.1700 +                                            local nIdx  = 7 - math.floor(nTemp)
  1.1701 +                                            if dbIdx[nIdx] == 0 then
  1.1702 +                                                return
  1.1703 +                                            elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
  1.1704 +                                                event.target.color = color.lightGrey
  1.1705 +                                                dbMrk[nIdx] = 0
  1.1706 +                                            elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
  1.1707 +                                                event.target.color = {192, 192, 192}
  1.1708 +                                                dbMrk[nIdx] = 0
  1.1709 +                                            elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
  1.1710 +                                                event.target.color = {220, 210, 120}
  1.1711 +                                                dbMrk[nIdx] = dbIdx[nIdx]
  1.1712 +                                            else
  1.1713 +                                                event.target.color = color.khaki
  1.1714 +                                                dbMrk[nIdx] = dbIdx[nIdx]
  1.1715 +                                            end
  1.1716 +                                        end
  1.1717 +                                    end
  1.1718 +                                    rectfresh:addEventListener('touch', rectfresh)
  1.1719 +                       
  1.1720 +                                    if nIter % 2 == 0 then
  1.1721 +                                        rectfresh.color = color.lightGrey
  1.1722 +                                    else
  1.1723 +                                        rectfresh.color = {192, 192, 192}
  1.1724 +                                    end
  1.1725 +                       
  1.1726 +                                    -- Clear indexes
  1.1727 +                                    dbIdx[nIter+1] = 0
  1.1728 +                                    dbMrk[nIter+1] = 0
  1.1729 +                                end
  1.1730 +                       
  1.1731 +                                -- Redraw labels
  1.1732 +                                local nIter = 6
  1.1733 +                                --for nIter = 0, 7 do
  1.1734 +                                local nTemp = nCount - nScroll
  1.1735 +                                if nTemp < 7 then
  1.1736 +                                    nIter = nTemp - 1
  1.1737 +                                end
  1.1738 +                       
  1.1739 +                                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.1740 +                                for dbRows in debe:nrows('SELECT * FROM qsos') do
  1.1741 +                                    if nTemp < 8 then
  1.1742 +                                        if nTemp < 0 then break end
  1.1743 +                                        if nIter < 0 then break end
  1.1744 +                                        local labrepop = director:createLabel({
  1.1745 +                                            x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
  1.1746 +                                            hAlignment='left', vAlignment='bottom',
  1.1747 +                                            font=fontsegoe,
  1.1748 +                                            text=dbRows['call']
  1.1749 +                                        })
  1.1750 +                                        dbIdx[nIter+1] = dbRows['id']
  1.1751 +                                        nIter = nIter - 1
  1.1752 +                                        nTemp = nTemp - 1
  1.1753 +                                    else
  1.1754 +                                        nTemp = nTemp - 1
  1.1755 +                                    end
  1.1756 +                                end
  1.1757 +                                debe:close()
  1.1758 +                                debe = nil
  1.1759 +                            end
  1.1760 +                            posMove = 0
  1.1761 +                        end
  1.1762 +                    end
  1.1763 +                    rectfresh:addEventListener('touch', rectfresh)
  1.1764 +
  1.1765 +                    if nIter % 2 == 0 then
  1.1766 +                        rectfresh.color = color.lightGrey
  1.1767 +                    else
  1.1768 +                        rectfresh.color = {192, 192, 192}
  1.1769 +                    end
  1.1770 +
  1.1771 +                    -- Clear indexes
  1.1772 +                    dbIdx[nIter+1] = 0
  1.1773 +                    dbMrk[nIter+1] = 0
  1.1774 +                end
  1.1775 +
  1.1776 +                -- Redraw labels
  1.1777 +                local nIter = 6
  1.1778 +                --for nIter = 0, 7 do
  1.1779 +                local nTemp = nCount - nScroll
  1.1780 +                if nTemp < 7 then
  1.1781 +                    nIter = nTemp - 1
  1.1782 +                end
  1.1783 +
  1.1784 +                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.1785 +                for dbRows in debe:nrows('SELECT * FROM qsos') do
  1.1786 +                    if nTemp < 8 then
  1.1787 +                        if nTemp < 0 then break end
  1.1788 +                        if nIter < 0 then break end
  1.1789 +                        local labrepop = director:createLabel({
  1.1790 +                            x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
  1.1791 +                            hAlignment='left', vAlignment='bottom',
  1.1792 +                            font=fontsegoe,
  1.1793 +                            text=dbRows['call']
  1.1794 +                        })
  1.1795 +                        dbIdx[nIter+1] = dbRows['id']
  1.1796 +                        nIter = nIter - 1
  1.1797 +                        nTemp = nTemp - 1
  1.1798 +                    else
  1.1799 +                        nTemp = nTemp - 1
  1.1800 +                    end
  1.1801 +                end
  1.1802 +                debe:close()
  1.1803 +                debe = nil
  1.1804 +            end
  1.1805 +            posMove = 0
  1.1806 +        end
  1.1807 +    end
  1.1808 +    rectsieb:addEventListener('touch', rectsieb)
  1.1809 +
  1.1810 +    -- Provide callback to count rows in table
  1.1811 +    local nCount = 0
  1.1812 +    function countrows(udata, cols, values, names)
  1.1813 +        assert(udata == 'dingdong')
  1.1814 +        nCount = tonumber(values[1])
  1.1815 +        return 0
  1.1816 +    end
  1.1817 +
  1.1818 +    -- Populate UI
  1.1819 +    debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.1820 +    local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
  1.1821 +    local nTemp = nCount
  1.1822 +    local nIter = 6;  --for nIter = 0, 7 do
  1.1823 +    if nTemp < 7 then
  1.1824 +        nIter = nTemp - 1
  1.1825 +    end
  1.1826 +
  1.1827 +    for dbRows in debe:nrows('SELECT * FROM qsos') do
  1.1828 +        if nTemp < 8 then
  1.1829 +            if nIter < 0 then break end
  1.1830 +            local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
  1.1831 +
  1.1832 +            function rectfresh:touch(event)
  1.1833 +                if event.phase == 'began' then
  1.1834 +                    posMove = event.y
  1.1835 +                    if event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
  1.1836 +                        event.target.color = color.lightGrey
  1.1837 +                    elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
  1.1838 +                        event.target.color = {192, 192, 192}
  1.1839 +                    elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
  1.1840 +                        event.target.color = {220, 210, 120}
  1.1841 +                    else
  1.1842 +                        event.target.color = color.khaki
  1.1843 +                    end
  1.1844 +                end
  1.1845 +            end
  1.1846 +            rectfresh:addEventListener('touch', rectfresh)
  1.1847 +
  1.1848 +            if nIter % 2 == 0 then
  1.1849 +                rectfresh.color = color.lightGrey
  1.1850 +            else
  1.1851 +                rectfresh.color = {192, 192, 192}
  1.1852 +            end
  1.1853 +
  1.1854 +            local labpopo = director:createLabel({
  1.1855 +                x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
  1.1856 +                hAlignment='left', vAlignment='bottom',
  1.1857 +                font=fontsegoe,
  1.1858 +                text=dbRows['call']
  1.1859 +            })
  1.1860 +            dbIdx[nIter+1] = dbRows['id']
  1.1861 +            nIter = nIter - 1
  1.1862 +            nTemp = nTemp - 1
  1.1863 +        else
  1.1864 +            nTemp = nTemp - 1
  1.1865 +        end
  1.1866 +    end
  1.1867 +    debe:close()
  1.1868 +    debe = nil
  1.1869 +
  1.1870 +    local butdel = director:createSprite(0, 0, 'images/buttdel1.png')
  1.1871 +    local butadd = director:createSprite(0, 0, 'images/buttadd.png')
  1.1872 +
  1.1873 +    butdel.color = color.white
  1.1874 +    butdel.x = (dsw - butdel.w - butadd.w) / 3
  1.1875 +    butdel.y = (dsh-fontarial.height*12)/2
  1.1876 +    butdel.xAnchor = 0
  1.1877 +    butdel.yAnchor = 0.5
  1.1878 +    --butdel.xScale = 5
  1.1879 +    --butdel.yScale = 1.25
  1.1880 +
  1.1881 +    butadd.color = color.white
  1.1882 +    butadd.x = dsw-dsw/8
  1.1883 +    butadd.x = dsw - (dsw - butdel.w - butadd.w) / 3
  1.1884 +    butadd.y = (dsh-fontarial.height*12)/2
  1.1885 +    butadd.xAnchor = 1
  1.1886 +    butadd.yAnchor = 0.5
  1.1887 +
  1.1888 +    -- Good transitions: slideInL/R, shrinkGrow, crossFade, fadeTR/BL, pageTurn, progressVertical
  1.1889 +    --local transoptl = {transitionType = 'progressHorizontal', transitionTime = 0.5}
  1.1890 +    local transoptr = {transitionType = 'slideInR', transitionTime = 0.5}
  1.1891 +
  1.1892 +    function butabout:touch(event)
  1.1893 +        if event.phase == 'began' then
  1.1894 +            director:moveToScene(sceneAbout, transoptr)
  1.1895 +        end
  1.1896 +    end
  1.1897 +    butabout:addEventListener('touch', butabout)
  1.1898 +
  1.1899 +    function buthelp:touch(event)
  1.1900 +        if event.phase == 'began' then
  1.1901 +            director:moveToScene(sceneHelp, transoptr)
  1.1902 +        end
  1.1903 +    end
  1.1904 +    buthelp:addEventListener('touch', buthelp)
  1.1905 +
  1.1906 +    -- String reader events handler
  1.1907 +    function gotString(event)
  1.1908 +        if (event.type == 'error') then
  1.1909 +            dbg.print('Error reading string: ' .. event.text)
  1.1910 +        elseif (event.type == 'read') then
  1.1911 +            dbg.print('String read: ' .. event.text)
  1.1912 +        end
  1.1913 +    end
  1.1914 +
  1.1915 +    function butadd:touch(event)
  1.1916 +        if (event.phase == 'began') then
  1.1917 +            -- Ensure that the string reading extension is available
  1.1918 +            if nui:isReadStringAvailable() then
  1.1919 +                -- Add a string reader event handler
  1.1920 +                system:addEventListener('stringread', gotString)
  1.1921 +
  1.1922 +                -- Create the string reader
  1.1923 +                widginput = nui:readString('New QSO Entry', '', 'Call Sign, QTH, Notes...')
  1.1924 +                if widginput then
  1.1925 +                    debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.1926 +                    debe:exec('INSERT INTO qsos VALUES(NULL, \'' .. widginput .. '\')')
  1.1927 +                    --debe:exec[=[
  1.1928 +                    --    INSERT INTO qsos VALUES(NULL, widginput);
  1.1929 +                    --]=]
  1.1930 +                    debe:close()
  1.1931 +                    debe = nil
  1.1932 +
  1.1933 +                    -- Provide callback to count rows in table
  1.1934 +                    local nCount = 0
  1.1935 +                    function countrows(udata, cols, values, names)
  1.1936 +                        assert(udata == 'dingdong')
  1.1937 +                        nCount = tonumber(values[1])
  1.1938 +                        return 0
  1.1939 +                    end
  1.1940 +
  1.1941 +                    -- Repopulate UI
  1.1942 +                    debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.1943 +                    local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
  1.1944 +                    local nIter = 6
  1.1945 +                    --for nIter = 0, 7 do
  1.1946 +                    local nTemp = nCount
  1.1947 +                    if nTemp < 7 then
  1.1948 +                        nIter = nTemp - 1
  1.1949 +                    end
  1.1950 +
  1.1951 +                    for dbRows in debe:nrows('SELECT * FROM qsos') do
  1.1952 +                        if nTemp < 8 then
  1.1953 +                            if nIter < 0 then break end
  1.1954 +                            local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
  1.1955 +
  1.1956 +                            function rectfresh:touch(event)
  1.1957 +                                if event.phase == 'began' then
  1.1958 +                                    if event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
  1.1959 +                                        event.target.color = color.lightGrey
  1.1960 +                                    elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
  1.1961 +                                        event.target.color = {192, 192, 192}
  1.1962 +                                    elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
  1.1963 +                                        event.target.color = {220, 210, 120}
  1.1964 +                                    else
  1.1965 +                                        event.target.color = color.khaki
  1.1966 +                                    end
  1.1967 +                                end
  1.1968 +                            end
  1.1969 +                            rectfresh:addEventListener('touch', rectfresh)
  1.1970 +
  1.1971 +                            if nIter % 2 == 0 then
  1.1972 +                                rectfresh.color = color.lightGrey
  1.1973 +                            else
  1.1974 +                                rectfresh.color = {192, 192, 192}
  1.1975 +                            end
  1.1976 +
  1.1977 +                            local labrepop = director:createLabel({
  1.1978 +                                x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
  1.1979 +                                hAlignment='left', vAlignment='bottom',
  1.1980 +                                font=fontsegoe,
  1.1981 +                                text=dbRows['call']
  1.1982 +                            })
  1.1983 +                            dbIdx[nIter+1] = dbRows['id']
  1.1984 +                            nIter = nIter - 1
  1.1985 +                            nTemp = nTemp - 1
  1.1986 +                        else
  1.1987 +                            nTemp = nTemp - 1
  1.1988 +                        end
  1.1989 +                    end
  1.1990 +                    debe:close()
  1.1991 +                    debe = nil
  1.1992 +                end
  1.1993 +            else
  1.1994 +                dbg.print('String reading is not supported on this platform')
  1.1995 +            end
  1.1996 +        end
  1.1997 +
  1.1998 +        if event.phase == 'ended' then
  1.1999 +            if math.abs(event.y - posMove) > fontarial.height*1.5 then
  1.2000 +                -- Provide callback to count rows in table
  1.2001 +                local nCount = 0
  1.2002 +                function countrows(udata, cols, values, names)
  1.2003 +                    assert(udata == 'dingdong')
  1.2004 +                    nCount = tonumber(values[1])
  1.2005 +                    return 0
  1.2006 +                end
  1.2007 +
  1.2008 +                -- Repopulate UI conditionally
  1.2009 +                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.2010 +                local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
  1.2011 +                debe:close()
  1.2012 +                debe = nil
  1.2013 +
  1.2014 +                if event.y - posMove > 0 then  -- Gesture upward
  1.2015 +                    if nScroll + 7 < nCount then
  1.2016 +                        nScroll = nScroll + 7
  1.2017 +                    else
  1.2018 +                        return
  1.2019 +                    end
  1.2020 +                else -- Gesture downward
  1.2021 +                    if nScroll - 7 >= 0 then
  1.2022 +                        nScroll = nScroll - 7
  1.2023 +                    else
  1.2024 +                        return
  1.2025 +                    end
  1.2026 +                end
  1.2027 +
  1.2028 +                -- Kludge stucked event handlers
  1.2029 +                rectoddy:removeEventListener('touch', rectoddy)
  1.2030 +                recteven:removeEventListener('touch', recteven)
  1.2031 +                recthree:removeEventListener('touch', recthree)
  1.2032 +                rectfour:removeEventListener('touch', rectfour)
  1.2033 +                rectfive:removeEventListener('touch', rectfive)
  1.2034 +                rectseis:removeEventListener('touch', rectseis)
  1.2035 +                rectsieb:removeEventListener('touch', rectsieb)
  1.2036 +
  1.2037 +                -- Clear viewport
  1.2038 +                for nIter = 0, 6 do
  1.2039 +                    local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
  1.2040 +
  1.2041 +                    function rectfresh:touch(event)
  1.2042 +                        if event.phase == 'began' then
  1.2043 +                            posMove = event.y
  1.2044 +                            local nBase = event.y - (dsh - fontarial.height * 12)
  1.2045 +                            local nRect = fontarial.height * 1.5
  1.2046 +                            local nTemp = nBase / nRect
  1.2047 +                            local nIdx  = 7 - math.floor(nTemp)
  1.2048 +                            if dbIdx[nIdx] == 0 then
  1.2049 +                                return
  1.2050 +                            elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
  1.2051 +                                event.target.color = color.lightGrey
  1.2052 +                                dbMrk[nIdx] = 0
  1.2053 +                            elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
  1.2054 +                                event.target.color = {192, 192, 192}
  1.2055 +                                dbMrk[nIdx] = 0
  1.2056 +                            elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
  1.2057 +                                event.target.color = {220, 210, 120}
  1.2058 +                                dbMrk[nIdx] = dbIdx[nIdx]
  1.2059 +                            else
  1.2060 +                                event.target.color = color.khaki
  1.2061 +                                dbMrk[nIdx] = dbIdx[nIdx]
  1.2062 +                            end
  1.2063 +                        end
  1.2064 +                        if event.phase == 'ended' then
  1.2065 +                            if math.abs(event.y - posMove) > fontarial.height*1.5 then
  1.2066 +                                -- Provide callback to count rows in table
  1.2067 +                                local nCount = 0
  1.2068 +                                function countrows(udata, cols, values, names)
  1.2069 +                                    assert(udata == 'dingdong')
  1.2070 +                                    nCount = tonumber(values[1])
  1.2071 +                                    return 0
  1.2072 +                                end
  1.2073 +                       
  1.2074 +                                -- Repopulate UI conditionally
  1.2075 +                                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.2076 +                                local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
  1.2077 +                                debe:close()
  1.2078 +                                debe = nil
  1.2079 +                       
  1.2080 +                                if event.y - posMove > 0 then  -- Gesture upward
  1.2081 +                                    if nScroll + 7 < nCount then
  1.2082 +                                        nScroll = nScroll + 7
  1.2083 +                                    else
  1.2084 +                                        return
  1.2085 +                                    end
  1.2086 +                                else -- Gesture downward
  1.2087 +                                    if nScroll - 7 >= 0 then
  1.2088 +                                        nScroll = nScroll - 7
  1.2089 +                                    else
  1.2090 +                                        return
  1.2091 +                                    end
  1.2092 +                                end
  1.2093 +                       
  1.2094 +                                -- Kludge stucked event handlers
  1.2095 +                                rectoddy:removeEventListener('touch', rectoddy)
  1.2096 +                                recteven:removeEventListener('touch', recteven)
  1.2097 +                                recthree:removeEventListener('touch', recthree)
  1.2098 +                                rectfour:removeEventListener('touch', rectfour)
  1.2099 +                                rectfive:removeEventListener('touch', rectfive)
  1.2100 +                                rectseis:removeEventListener('touch', rectseis)
  1.2101 +                                rectsieb:removeEventListener('touch', rectsieb)
  1.2102 +
  1.2103 +                                -- Clear viewport
  1.2104 +                                for nIter = 0, 6 do
  1.2105 +                                    local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
  1.2106 +                       
  1.2107 +                                    function rectfresh:touch(event)
  1.2108 +                                        if event.phase == 'began' then
  1.2109 +                                            posMove = event.y
  1.2110 +                                            local nBase = event.y - (dsh - fontarial.height * 12)
  1.2111 +                                            local nRect = fontarial.height * 1.5
  1.2112 +                                            local nTemp = nBase / nRect
  1.2113 +                                            local nIdx  = 7 - math.floor(nTemp)
  1.2114 +                                            if dbIdx[nIdx] == 0 then
  1.2115 +                                                return
  1.2116 +                                            elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
  1.2117 +                                                event.target.color = color.lightGrey
  1.2118 +                                                dbMrk[nIdx] = 0
  1.2119 +                                            elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
  1.2120 +                                                event.target.color = {192, 192, 192}
  1.2121 +                                                dbMrk[nIdx] = 0
  1.2122 +                                            elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
  1.2123 +                                                event.target.color = {220, 210, 120}
  1.2124 +                                                dbMrk[nIdx] = dbIdx[nIdx]
  1.2125 +                                            else
  1.2126 +                                                event.target.color = color.khaki
  1.2127 +                                                dbMrk[nIdx] = dbIdx[nIdx]
  1.2128 +                                            end
  1.2129 +                                        end
  1.2130 +                                    end
  1.2131 +                                    rectfresh:addEventListener('touch', rectfresh)
  1.2132 +                       
  1.2133 +                                    if nIter % 2 == 0 then
  1.2134 +                                        rectfresh.color = color.lightGrey
  1.2135 +                                    else
  1.2136 +                                        rectfresh.color = {192, 192, 192}
  1.2137 +                                    end
  1.2138 +                       
  1.2139 +                                    -- Clear indexes
  1.2140 +                                    dbIdx[nIter+1] = 0
  1.2141 +                                    dbMrk[nIter+1] = 0
  1.2142 +                                end
  1.2143 +                       
  1.2144 +                                -- Redraw labels
  1.2145 +                                local nIter = 6
  1.2146 +                                --for nIter = 0, 7 do
  1.2147 +                                local nTemp = nCount - nScroll
  1.2148 +                                if nTemp < 7 then
  1.2149 +                                    nIter = nTemp - 1
  1.2150 +                                end
  1.2151 +                       
  1.2152 +                                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.2153 +                                for dbRows in debe:nrows('SELECT * FROM qsos') do
  1.2154 +                                    if nTemp < 8 then
  1.2155 +                                        if nTemp < 0 then break end
  1.2156 +                                        if nIter < 0 then break end
  1.2157 +                                        local labrepop = director:createLabel({
  1.2158 +                                            x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
  1.2159 +                                            hAlignment='left', vAlignment='bottom',
  1.2160 +                                            font=fontsegoe,
  1.2161 +                                            text=dbRows['call']
  1.2162 +                                        })
  1.2163 +                                        dbIdx[nIter+1] = dbRows['id']
  1.2164 +                                        nIter = nIter - 1
  1.2165 +                                        nTemp = nTemp - 1
  1.2166 +                                    else
  1.2167 +                                        nTemp = nTemp - 1
  1.2168 +                                    end
  1.2169 +                                end
  1.2170 +                                debe:close()
  1.2171 +                                debe = nil
  1.2172 +                            end
  1.2173 +                            posMove = 0
  1.2174 +                        end
  1.2175 +                    end
  1.2176 +                    rectfresh:addEventListener('touch', rectfresh)
  1.2177 +
  1.2178 +                    if nIter % 2 == 0 then
  1.2179 +                        rectfresh.color = color.lightGrey
  1.2180 +                    else
  1.2181 +                        rectfresh.color = {192, 192, 192}
  1.2182 +                    end
  1.2183 +
  1.2184 +                    -- Clear indexes
  1.2185 +                    dbIdx[nIter+1] = 0
  1.2186 +                    dbMrk[nIter+1] = 0
  1.2187 +                end
  1.2188 +
  1.2189 +                -- Redraw labels
  1.2190 +                local nIter = 6
  1.2191 +                --for nIter = 0, 7 do
  1.2192 +                local nTemp = nCount - nScroll
  1.2193 +                if nTemp < 7 then
  1.2194 +                    nIter = nTemp - 1
  1.2195 +                end
  1.2196 +
  1.2197 +                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.2198 +                for dbRows in debe:nrows('SELECT * FROM qsos') do
  1.2199 +                    if nTemp < 8 then
  1.2200 +                        if nTemp < 0 then break end
  1.2201 +                        if nIter < 0 then break end
  1.2202 +                        local labrepop = director:createLabel({
  1.2203 +                            x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
  1.2204 +                            hAlignment='left', vAlignment='bottom',
  1.2205 +                            font=fontsegoe,
  1.2206 +                            text=dbRows['call']
  1.2207 +                        })
  1.2208 +                        dbIdx[nIter+1] = dbRows['id']
  1.2209 +                        nIter = nIter - 1
  1.2210 +                        nTemp = nTemp - 1
  1.2211 +                    else
  1.2212 +                        nTemp = nTemp - 1
  1.2213 +                    end
  1.2214 +                end
  1.2215 +                debe:close()
  1.2216 +                debe = nil
  1.2217 +            end
  1.2218 +            posMove = 0
  1.2219 +        end
  1.2220 +    end
  1.2221 +    butadd:addEventListener('touch', butadd)
  1.2222 +
  1.2223 +    function butdel:touch(event)
  1.2224 +        if (event.phase == 'began') then
  1.2225 +            -- Provide callback to count rows in table
  1.2226 +            local nCount = 0
  1.2227 +            function countrows(udata, cols, values, names)
  1.2228 +                assert(udata == 'dingdong')
  1.2229 +                nCount = tonumber(values[1])
  1.2230 +                return 0
  1.2231 +            end
  1.2232 +
  1.2233 +            -- Iterate over visible rows, deleting
  1.2234 +            debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.2235 +            local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
  1.2236 +            local nTemp = nCount
  1.2237 +            local nIter = 0;  --for nIter = 0, 7 do
  1.2238 +
  1.2239 +            for dbRows in debe:nrows('SELECT * FROM qsos') do
  1.2240 +                if nTemp < 8 then
  1.2241 +                    if nIter > 6 then break end
  1.2242 +                    if dbMrk[nIter+1] ~= 0 then
  1.2243 +                        debe:exec('DELETE FROM qsos WHERE id = \'' .. dbRows['id'] .. '\'')
  1.2244 +                    end
  1.2245 +                    nIter = nIter + 1
  1.2246 +                    nTemp = nTemp - 1
  1.2247 +                else
  1.2248 +                    nTemp = nTemp - 1
  1.2249 +                end
  1.2250 +            end
  1.2251 +            debe:close()
  1.2252 +            debe = nil
  1.2253 +
  1.2254 +            -- Kludge stucked event handlers
  1.2255 +            rectoddy:removeEventListener('touch', rectoddy)
  1.2256 +            recteven:removeEventListener('touch', recteven)
  1.2257 +            recthree:removeEventListener('touch', recthree)
  1.2258 +            rectfour:removeEventListener('touch', rectfour)
  1.2259 +            rectfive:removeEventListener('touch', rectfive)
  1.2260 +            rectseis:removeEventListener('touch', rectseis)
  1.2261 +            rectsieb:removeEventListener('touch', rectsieb)
  1.2262 +
  1.2263 +            -- Clear viewport
  1.2264 +            for nIter = 0, 6 do
  1.2265 +                local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
  1.2266 +
  1.2267 +                function rectfresh:touch(event)
  1.2268 +                    if event.phase == 'began' then
  1.2269 +                        local nBase = event.y - (dsh - fontarial.height * 12)
  1.2270 +                        local nRect = fontarial.height * 1.5
  1.2271 +                        local nTemp = nBase / nRect
  1.2272 +                        local nIdx  = 7 - math.floor(nTemp)
  1.2273 +                        if dbIdx[nIdx] == 0 then
  1.2274 +                            return
  1.2275 +                        elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
  1.2276 +                            event.target.color = color.lightGrey
  1.2277 +                            dbMrk[nIdx] = 0
  1.2278 +                        elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
  1.2279 +                            event.target.color = {192, 192, 192}
  1.2280 +                            dbMrk[nIdx] = 0
  1.2281 +                        elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
  1.2282 +                            event.target.color = {220, 210, 120}
  1.2283 +                            dbMrk[nIdx] = dbIdx[nIdx]
  1.2284 +                        else
  1.2285 +                            event.target.color = color.khaki
  1.2286 +                            dbMrk[nIdx] = dbIdx[nIdx]
  1.2287 +                        end
  1.2288 +                    end
  1.2289 +                end
  1.2290 +                rectfresh:addEventListener('touch', rectfresh)
  1.2291 +
  1.2292 +                if nIter % 2 == 0 then
  1.2293 +                    rectfresh.color = color.lightGrey
  1.2294 +                else
  1.2295 +                    rectfresh.color = {192, 192, 192}
  1.2296 +                end
  1.2297 +
  1.2298 +                -- Clear indexes
  1.2299 +                dbIdx[nIter+1] = 0
  1.2300 +                dbMrk[nIter+1] = 0
  1.2301 +            end
  1.2302 +
  1.2303 +            -- Repopulate UI
  1.2304 +            debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.2305 +            local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
  1.2306 +            local nIter = 6
  1.2307 +            --for nIter = 0, 7 do
  1.2308 +            local nTemp = nCount
  1.2309 +            if nTemp < 7 then
  1.2310 +                nIter = nTemp - 1
  1.2311 +            end
  1.2312 +
  1.2313 +            for dbRows in debe:nrows('SELECT * FROM qsos') do
  1.2314 +                if nTemp < 8 then
  1.2315 +                    if nIter < 0 then break end
  1.2316 +                    local labrepop = director:createLabel({
  1.2317 +                        x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
  1.2318 +                        hAlignment='left', vAlignment='bottom',
  1.2319 +                        font=fontsegoe,
  1.2320 +                        text=dbRows['call']
  1.2321 +                    })
  1.2322 +                    dbIdx[nIter+1] = dbRows['id']
  1.2323 +                    nIter = nIter - 1
  1.2324 +                    nTemp = nTemp - 1
  1.2325 +                else
  1.2326 +                    nTemp = nTemp - 1
  1.2327 +                end
  1.2328 +            end
  1.2329 +            debe:close()
  1.2330 +            debe = nil
  1.2331 +        end
  1.2332 +
  1.2333 +        if event.phase == 'ended' then
  1.2334 +            if math.abs(event.y - posMove) > fontarial.height*1.5 then
  1.2335 +                -- Provide callback to count rows in table
  1.2336 +                local nCount = 0
  1.2337 +                function countrows(udata, cols, values, names)
  1.2338 +                    assert(udata == 'dingdong')
  1.2339 +                    nCount = tonumber(values[1])
  1.2340 +                    return 0
  1.2341 +                end
  1.2342 +
  1.2343 +                -- Repopulate UI conditionally
  1.2344 +                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.2345 +                local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
  1.2346 +                debe:close()
  1.2347 +                debe = nil
  1.2348 +
  1.2349 +                if event.y - posMove > 0 then  -- Gesture upward
  1.2350 +                    if nScroll + 7 < nCount then
  1.2351 +                        nScroll = nScroll + 7
  1.2352 +                    else
  1.2353 +                        return
  1.2354 +                    end
  1.2355 +                else -- Gesture downward
  1.2356 +                    if nScroll - 7 >= 0 then
  1.2357 +                        nScroll = nScroll - 7
  1.2358 +                    else
  1.2359 +                        return
  1.2360 +                    end
  1.2361 +                end
  1.2362 +
  1.2363 +                -- Kludge stucked event handlers
  1.2364 +                rectoddy:removeEventListener('touch', rectoddy)
  1.2365 +                recteven:removeEventListener('touch', recteven)
  1.2366 +                recthree:removeEventListener('touch', recthree)
  1.2367 +                rectfour:removeEventListener('touch', rectfour)
  1.2368 +                rectfive:removeEventListener('touch', rectfive)
  1.2369 +                rectseis:removeEventListener('touch', rectseis)
  1.2370 +                rectsieb:removeEventListener('touch', rectsieb)
  1.2371 +
  1.2372 +                -- Clear viewport
  1.2373 +                for nIter = 0, 6 do
  1.2374 +                    local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
  1.2375 +
  1.2376 +                    function rectfresh:touch(event)
  1.2377 +                        if event.phase == 'began' then
  1.2378 +                            posMove = event.y
  1.2379 +                            local nBase = event.y - (dsh - fontarial.height * 12)
  1.2380 +                            local nRect = fontarial.height * 1.5
  1.2381 +                            local nTemp = nBase / nRect
  1.2382 +                            local nIdx  = 7 - math.floor(nTemp)
  1.2383 +                            if dbIdx[nIdx] == 0 then
  1.2384 +                                return
  1.2385 +                            elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
  1.2386 +                                event.target.color = color.lightGrey
  1.2387 +                                dbMrk[nIdx] = 0
  1.2388 +                            elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
  1.2389 +                                event.target.color = {192, 192, 192}
  1.2390 +                                dbMrk[nIdx] = 0
  1.2391 +                            elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
  1.2392 +                                event.target.color = {220, 210, 120}
  1.2393 +                                dbMrk[nIdx] = dbIdx[nIdx]
  1.2394 +                            else
  1.2395 +                                event.target.color = color.khaki
  1.2396 +                                dbMrk[nIdx] = dbIdx[nIdx]
  1.2397 +                            end
  1.2398 +                        end
  1.2399 +                        if event.phase == 'ended' then
  1.2400 +                            if math.abs(event.y - posMove) > fontarial.height*1.5 then
  1.2401 +                                -- Provide callback to count rows in table
  1.2402 +                                local nCount = 0
  1.2403 +                                function countrows(udata, cols, values, names)
  1.2404 +                                    assert(udata == 'dingdong')
  1.2405 +                                    nCount = tonumber(values[1])
  1.2406 +                                    return 0
  1.2407 +                                end
  1.2408 +                       
  1.2409 +                                -- Repopulate UI conditionally
  1.2410 +                                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.2411 +                                local nRet = debe:exec('SELECT Count(*) FROM qsos', countrows, 'dingdong')
  1.2412 +                                debe:close()
  1.2413 +                                debe = nil
  1.2414 +                       
  1.2415 +                                if event.y - posMove > 0 then  -- Gesture upward
  1.2416 +                                    if nScroll + 7 < nCount then
  1.2417 +                                        nScroll = nScroll + 7
  1.2418 +                                    else
  1.2419 +                                        return
  1.2420 +                                    end
  1.2421 +                                else -- Gesture downward
  1.2422 +                                    if nScroll - 7 >= 0 then
  1.2423 +                                        nScroll = nScroll - 7
  1.2424 +                                    else
  1.2425 +                                        return
  1.2426 +                                    end
  1.2427 +                                end
  1.2428 +                       
  1.2429 +                                -- Kludge stucked event handlers
  1.2430 +                                rectoddy:removeEventListener('touch', rectoddy)
  1.2431 +                                recteven:removeEventListener('touch', recteven)
  1.2432 +                                recthree:removeEventListener('touch', recthree)
  1.2433 +                                rectfour:removeEventListener('touch', rectfour)
  1.2434 +                                rectfive:removeEventListener('touch', rectfive)
  1.2435 +                                rectseis:removeEventListener('touch', rectseis)
  1.2436 +                                rectsieb:removeEventListener('touch', rectsieb)
  1.2437 +
  1.2438 +                                -- Clear viewport
  1.2439 +                                for nIter = 0, 6 do
  1.2440 +                                    local rectfresh = director:createRectangle(0, (dsh - fontarial.height * 3 - nIter * fontarial.height * 1.5), dsw, fontarial.height * 1.5)
  1.2441 +                       
  1.2442 +                                    function rectfresh:touch(event)
  1.2443 +                                        if event.phase == 'began' then
  1.2444 +                                            posMove = event.y
  1.2445 +                                            local nBase = event.y - (dsh - fontarial.height * 12)
  1.2446 +                                            local nRect = fontarial.height * 1.5
  1.2447 +                                            local nTemp = nBase / nRect
  1.2448 +                                            local nIdx  = 7 - math.floor(nTemp)
  1.2449 +                                            if dbIdx[nIdx] == 0 then
  1.2450 +                                                return
  1.2451 +                                            elseif event.target.color.r == 240 and event.target.color.g == 230 and event.target.color.b == 140 then
  1.2452 +                                                event.target.color = color.lightGrey
  1.2453 +                                                dbMrk[nIdx] = 0
  1.2454 +                                            elseif event.target.color.r == 220 and event.target.color.g == 210 and event.target.color.b == 120 then
  1.2455 +                                                event.target.color = {192, 192, 192}
  1.2456 +                                                dbMrk[nIdx] = 0
  1.2457 +                                            elseif event.target.color.r == 192 and event.target.color.g == 192 and event.target.color.b == 192 then
  1.2458 +                                                event.target.color = {220, 210, 120}
  1.2459 +                                                dbMrk[nIdx] = dbIdx[nIdx]
  1.2460 +                                            else
  1.2461 +                                                event.target.color = color.khaki
  1.2462 +                                                dbMrk[nIdx] = dbIdx[nIdx]
  1.2463 +                                            end
  1.2464 +                                        end
  1.2465 +                                    end
  1.2466 +                                    rectfresh:addEventListener('touch', rectfresh)
  1.2467 +                       
  1.2468 +                                    if nIter % 2 == 0 then
  1.2469 +                                        rectfresh.color = color.lightGrey
  1.2470 +                                    else
  1.2471 +                                        rectfresh.color = {192, 192, 192}
  1.2472 +                                    end
  1.2473 +                       
  1.2474 +                                    -- Clear indexes
  1.2475 +                                    dbIdx[nIter+1] = 0
  1.2476 +                                    dbMrk[nIter+1] = 0
  1.2477 +                                end
  1.2478 +                       
  1.2479 +                                -- Redraw labels
  1.2480 +                                local nIter = 6
  1.2481 +                                --for nIter = 0, 7 do
  1.2482 +                                local nTemp = nCount - nScroll
  1.2483 +                                if nTemp < 7 then
  1.2484 +                                    nIter = nTemp - 1
  1.2485 +                                end
  1.2486 +                       
  1.2487 +                                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.2488 +                                for dbRows in debe:nrows('SELECT * FROM qsos') do
  1.2489 +                                    if nTemp < 8 then
  1.2490 +                                        if nTemp < 0 then break end
  1.2491 +                                        if nIter < 0 then break end
  1.2492 +                                        local labrepop = director:createLabel({
  1.2493 +                                            x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
  1.2494 +                                            hAlignment='left', vAlignment='bottom',
  1.2495 +                                            font=fontsegoe,
  1.2496 +                                            text=dbRows['call']
  1.2497 +                                        })
  1.2498 +                                        dbIdx[nIter+1] = dbRows['id']
  1.2499 +                                        nIter = nIter - 1
  1.2500 +                                        nTemp = nTemp - 1
  1.2501 +                                    else
  1.2502 +                                        nTemp = nTemp - 1
  1.2503 +                                    end
  1.2504 +                                end
  1.2505 +                                debe:close()
  1.2506 +                                debe = nil
  1.2507 +                            end
  1.2508 +                            posMove = 0
  1.2509 +                        end
  1.2510 +                    end
  1.2511 +                    rectfresh:addEventListener('touch', rectfresh)
  1.2512 +
  1.2513 +                    if nIter % 2 == 0 then
  1.2514 +                        rectfresh.color = color.lightGrey
  1.2515 +                    else
  1.2516 +                        rectfresh.color = {192, 192, 192}
  1.2517 +                    end
  1.2518 +
  1.2519 +                    -- Clear indexes
  1.2520 +                    dbIdx[nIter+1] = 0
  1.2521 +                    dbMrk[nIter+1] = 0
  1.2522 +                end
  1.2523 +
  1.2524 +                -- Redraw labels
  1.2525 +                local nIter = 6
  1.2526 +                --for nIter = 0, 7 do
  1.2527 +                local nTemp = nCount - nScroll
  1.2528 +                if nTemp < 7 then
  1.2529 +                    nIter = nTemp - 1
  1.2530 +                end
  1.2531 +
  1.2532 +                debe = sqlite3.open(pathStor .. 'amalog.sql')
  1.2533 +                for dbRows in debe:nrows('SELECT * FROM qsos') do
  1.2534 +                    if nTemp < 8 then
  1.2535 +                        if nTemp < 0 then break end
  1.2536 +                        if nIter < 0 then break end
  1.2537 +                        local labrepop = director:createLabel({
  1.2538 +                            x=fontsegoe.height/2, y=dsh-fontarial.height*(3+nIter*1.5) + (fontsegoe.height/3),
  1.2539 +                            hAlignment='left', vAlignment='bottom',
  1.2540 +                            font=fontsegoe,
  1.2541 +                            text=dbRows['call']
  1.2542 +                        })
  1.2543 +                        dbIdx[nIter+1] = dbRows['id']
  1.2544 +                        nIter = nIter - 1
  1.2545 +                        nTemp = nTemp - 1
  1.2546 +                    else
  1.2547 +                        nTemp = nTemp - 1
  1.2548 +                    end
  1.2549 +                end
  1.2550 +                debe:close()
  1.2551 +                debe = nil
  1.2552 +            end
  1.2553 +            posMove = 0
  1.2554 +        end
  1.2555 +    end
  1.2556 +    butdel:addEventListener('touch', butdel)
  1.2557 +end
  1.2558 +
  1.2559 +function sceneloc:tearDown(event)
  1.2560 +    dbg.print('sceneloc:tearDown')
  1.2561 +    --rectfresh:removeEventListener('touch', rectfresh)
  1.2562 +    rectoddy:removeEventListener('touch', rectoddy)
  1.2563 +    recteven:removeEventListener('touch', recteven)
  1.2564 +    recthree:removeEventListener('touch', recthree)
  1.2565 +    rectfour:removeEventListener('touch', rectfour)
  1.2566 +    rectfive:removeEventListener('touch', rectfive)
  1.2567 +    rectseis:removeEventListener('touch', rectseis)
  1.2568 +    rectsieb:removeEventListener('touch', rectsieb)
  1.2569 +    --self.obj0:removeFromParent()
  1.2570 +    --self.obj1:removeFromParent()
  1.2571 +    --self.obj0 = nil
  1.2572 +    --self.obj1 = nil
  1.2573 +end
  1.2574 +function sceneloc:enterPreTransition(event)
  1.2575 +    dbg.print('sceneloc:enterPreTransition')
  1.2576 +end
  1.2577 +function sceneloc:enterPostTransition(event)
  1.2578 +    dbg.print('sceneloc:enterPostTransition')
  1.2579 +end
  1.2580 +function sceneloc:exitPreTransition(event)
  1.2581 +    dbg.print('sceneloc:exitPreTransition')
  1.2582 +end
  1.2583 +function sceneloc:exitPostTransition(event)
  1.2584 +    dbg.print('sceneloc:exitPostTransition')
  1.2585 +end
  1.2586 +
  1.2587 +sceneloc:addEventListener({'setUp', 'tearDown', 'enterPreTransition',
  1.2588 +    'enterPostTransition', 'exitPreTransition', 'exitPostTransition'}, sceneloc)
  1.2589 +
  1.2590 +return sceneloc

mercurial