友達。
添付ファイルに、IUP gui を使用した Lua 言語でのフォームの例を示します。
必要なのは、最初のテキスト ボックスでキーを押すたびに何らかの計算を行い、その結果を 2 番目のテキスト ボックスに表示する必要があることです。
私が見つけた問題は、最近答えが表示されていることです...これは...
数字が押されました...しかし、結果は表示されません。
2 番目の数字が押された....表示される結果は、最初のテキスト ボックスに最初の数字のみが表示されているかのようです。
3 番目の数字が押された....表示される結果は、最初のテキスト ボックスに最初の 2 桁があるかのようになります。
等々。
コードのどこに矛盾があるのか教えていただけますか?
私の目標は、7GUIs で提案されている 7 つの GUI を開発することです: https://github.com/eugenkiss/7guis
しかし、このようにいくつかの点を解決する必要があります。
友よありがとう。
ヘルナン。
---------------------------------
-- Temperatura.lua
-- Hernán Cano Martínez
-- Ene-2018
---------------------------------
package.cpath = "?.dll;?53.dll;lua533/?.dll;lua533/?53.dll;" -- [in Windows]
require ( "iuplua" )
-- iup.key_open() -- is obsolete and not necessary anymore in since IUP 3.0 RC 3 .
-- ***************************************************************************
-- los controles que usaremos en nuestro formulario
txtC = iup.text { value="0" , expand='NO', floating='NO', rastersize = "70" , cx="030", cy= "30", font ="Courier New, 10", NC='10', ACTIVE='YES', ALIGNMENT='ACENTER' }
lblC = iup.label { title = "Celsius =", expand='NO', floating='NO', rastersize = "85x25", cx="110", cy= "27", font ="Courier New, 10" } -- size in pixels
txtF = iup.text { value="0" , expand='NO', floating='NO', rastersize = "70" , cx="200", cy= "30", font ="Courier New, 10", NC='10', ACTIVE='YES', ALIGNMENT='ACENTER' }
lblF = iup.label { title = "Farenheit", expand='NO', floating='NO', rastersize = "85x25", cx="280", cy= "27", font ="Courier New, 10" } -- size in pixels
btnC = iup.button { title = "Cerrar" , expand='NO', floating='NO', rastersize = "75x25", cx="200", cy="100", font ="Segoe IU, 9", TIP='Haga click para cerrar' }
-- ***************************************************************************
-- el Contenedor de controles
vArea = iup.cbox{ expand='NO', floating='NO', size = "450x200",
txtC, lblC, txtF, lblF, --btnC,
nil
}
-- El formulario
frmTemperatura = iup.dialog{ expand='NO', floating='NO',
vArea,
title = "Temperatura",
size = "300x100"
}
-- ********************************** Callbacks *****************************************
function btnC:action()
-- Exits the main loop
return iup.CLOSE
end
function txtC:action(t)
if txtC.value and tonumber(txtC.value) then
local nNum = 0
nNum = tonumber(txtC.value)
txtF.value = nNum * (9/5) + 32
end
-- return iup.CONTINUE -- HCM: I am not sure
end
function txtF:action(t)
if txtF.value and tonumber(txtF.value) then
local nNum = 0
nNum = tonumber(txtF.value)
txtC.value = nNum * (9/5) + 32
end
-- return iup.CONTINUE -- HCM: I am not sure
end
--------------------------------------------
-- Ahora sí: mostremos el formulario
frmTemperatura:showxy(iup.CENTER,iup.CENTER)
-- to be able to run this script inside another context
-- if (iup.MainLoopLevel()==0) then
if (not iup.MainLoopLevel or iup.MainLoopLevel()==0) then
iup.MainLoop()
end
----------------------------------------------