Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Bug Reports

Reply
 
Thread Tools Display Modes
Old 07-13-2018, 11:22 AM   #1
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 5,552
Default API: gfx.getchar(x) doesn't reset for non-letter keys

As per the API documentation, calling gfx.getchar with a character value checks the state of that key... but for anything other than letters it only works once. The function continues returning 1 until the script is closed.

Example code below. Run it, press some keys, watch the displayed keys:
Code:
gfx.init("getchar issue", 320, 240, 0, 30, 30)

local function Main()

    local char = math.floor(gfx.getchar())
    if char == -1 or char == 27 then
        gfx.quit()
        return
    end	

    local chars = {}
    for i = 1, 200 do
        local char = math.floor(gfx.getchar(i))
        if char and char ~= 0 then
            chars[#chars+1] = string.char(i)
        end
    end

    gfx.x, gfx.y = 16, 16
    gfx.drawstr(table.concat(chars, "\n"))

    gfx.update()
    reaper.defer(Main)
    
end

Main()
__________________
Currently enrolled in a coding bootcamp; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack

Last edited by Lokasenna; 07-13-2018 at 11:30 AM.
Lokasenna is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 12:22 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.