2d.editor
Voir le premier message non lu • 9 messages
• Page 1 sur 1
2d.editor
help !! getFormattedExpression() ?????? 2d.editor parameter ???
-
el_mix17
Niveau 3: MH (Membre Habitué)- Messages: 10
- Inscription: 21 Mai 2015, 00:54
- Genre:
- Calculatrice(s):→ MyCalcs profile
Re: 2d.editor
D2Editor:getFormattedExpression
it not a public API (nor is it available in standard Lua, only in QnA Lua).You may be looking for getExpression instead. This link has an example.
Also, see the official Nspire API PDF.
MyCalcs: Help the community's calculator documentations by filling out your calculators info!
MyCalcs: Aidez la communauté à documenter les calculatrices en donnant des infos sur vos calculatrices !
Inspired-Lua.org: All about TI-Nspire Lua programming (tutorials, wiki/docs...)-
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)- Messages: 14613
- Images: 1218
- Inscription: 01 Juin 2007, 00:00
- Localisation: France
- Genre:
- Calculatrice(s):→ MyCalcs profile
- Twitter/X: adriweb
- GitHub: adriweb
Re: 2d.editor
Help me get the numerical value of a text box to use mathematics in var.store and use that value in another application
ayuda
ayuda
- Code: Tout sélectionner
local cuadro= D2Editor.newRichText()
function on.paint(gc)
gc:drawString("Valor =",60,5)
cuadro:move(125,5)
cuadro:resize(35,25)
cuadro:createMathBox()
cuadro:registerFilter({tabKey = function() cuadro:setFocus(false) end,enterKey = function () cuadro: setFocus(false) end})
local variable = cuadro:getExpression()
var.store("salida",variable)
end
-
el_mix17
Niveau 3: MH (Membre Habitué)- Messages: 10
- Inscription: 21 Mai 2015, 00:54
- Genre:
- Calculatrice(s):→ MyCalcs profile
Re: 2d.editor
If you don't need actual math formatting, just remove the "createMathBox" part. If you do need it, you'll need to filter out the "\0el {" at the start and "}" at the beginning (with string.sub)
Here I recoded your thing (not tested...) to set the Basic variable "salida" only when pressing the enterKey
Don't do anythign else than drawing inside the on.paint(gc) method.
Here I recoded your thing (not tested...) to set the Basic variable "salida" only when pressing the enterKey
- Code: Tout sélectionner
function on.construction()
cuadro = D2Editor.newRichText()
cuadro:move(125, 5)
:resize(35, 25)
:setBorder(1)
:setFocus(true)
:registerFilter( { tabKey = function() cuadro:setFocus(false) end,
enterKey = function() cuadro:setFocus(false) var.store("salida", cuadro:getExpression()) end } )
end
function on.paint(gc)
gc:drawString("Valor =", 60, 5)
end
Don't do anythign else than drawing inside the on.paint(gc) method.
MyCalcs: Help the community's calculator documentations by filling out your calculators info!
MyCalcs: Aidez la communauté à documenter les calculatrices en donnant des infos sur vos calculatrices !
Inspired-Lua.org: All about TI-Nspire Lua programming (tutorials, wiki/docs...)-
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)- Messages: 14613
- Images: 1218
- Inscription: 01 Juin 2007, 00:00
- Localisation: France
- Genre:
- Calculatrice(s):→ MyCalcs profile
- Twitter/X: adriweb
- GitHub: adriweb
Re: 2d.editor
gracias... otra pregunta
comando ???
comando ???
-
el_mix17
Niveau 3: MH (Membre Habitué)- Messages: 10
- Inscription: 21 Mai 2015, 00:54
- Genre:
- Calculatrice(s):→ MyCalcs profile
Re: 2d.editor
Interesting, I suppose they forgot to remove it from there....
MyCalcs: Help the community's calculator documentations by filling out your calculators info!
MyCalcs: Aidez la communauté à documenter les calculatrices en donnant des infos sur vos calculatrices !
Inspired-Lua.org: All about TI-Nspire Lua programming (tutorials, wiki/docs...)-
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)- Messages: 14613
- Images: 1218
- Inscription: 01 Juin 2007, 00:00
- Localisation: France
- Genre:
- Calculatrice(s):→ MyCalcs profile
- Twitter/X: adriweb
- GitHub: adriweb
Re: 2d.editor
gracias por sus respuestas
me podría dar algún consejo de como estructurar este código ??
soy novato en esto
me podría dar algún consejo de como estructurar este código ??
- Code: Tout sélectionner
platform.apilevel = '2.3'
--variables de la viga interio
--cajas de texto
local b_v_p= D2Editor.newRichText()
local bw_v_p= D2Editor.newRichText()
local h_v_p= D2Editor.newRichText()
local hf_v_p= D2Editor.newRichText()
local d_v_p= D2Editor.newRichText()
b_v_p:setFocus(true)
--variables de la viga lateral
--cajas de texto
local b_v_l= D2Editor.newRichText()
local bw_v_l= D2Editor.newRichText()
local h_v_l= D2Editor.newRichText()
local hf_v_l= D2Editor.newRichText()
local d_v_l= D2Editor.newRichText()
--fin de las variables de las vigas
salida = nil
function tipo_v(tipo)
if tipo==1 then
salida =1
elseif tipo==2 then
salida =2
elseif tipo==3 then
salida =3
elseif tipo==4 then
salida =4
end
platform.window:invalidate()
end
--funcion que dibuja la viga T principal
function viga_t_p(gc)
gc:drawString("Viga Interior ",20,20)
gc:setPen("medium","smooth")
gc:drawPolyLine({85,70,205,70,205,105,170,105,170,165,120,165,120,105,85,105,85,70})
gc:setPen("thin","smooth")
gc:drawRect(125,75,40,85)
gc:drawLine(160,75,150,85)
gc:drawLine(165,81,155,92)
--cotas
gc:setColorRGB(255,0,0)
--cota de b
gc:drawLine(85,55,85,65)
gc:drawLine(85,60,100,60)
gc:drawLine(205,55,205,65)
gc:drawLine(190,60,205,60)
--cota de h
gc:drawLine(70,70,80,70)
gc:drawLine(70,165,80,165)
gc:drawLine(75,70,75,85)
gc:drawLine(75,150,75,165)
--cota de bw
gc:drawLine(120,170,120,180)
gc:drawLine(170,170,170,180)
gc:drawLine(120,175,170,175)
--cota de hf
gc:drawLine(210,70,220,70)
gc:drawLine(210,105,220,105)
gc:drawLine(215,70,215,105)
--cota de d
gc:drawLine(275,70,285,70)
gc:drawLine(275,155,285,155)
gc:drawLine(280,70,280,85)
gc:drawLine(280,155,280,140)
gc:setPen("thin","dashed")
gc:drawLine(120,155,275,155)
--fin de cotas
--simbolos de cotas
gc:setFont("serif","i",10)
gc:setColorRGB(0,0,0)
gc:drawString(" b = cm ",100,50)
gc:drawString(" h = cm ",25,110)
gc:drawString(" bw = cm ",100,180)
gc:drawString(" hf = cm ",215,75)
gc:drawString(" d = cm ",215,110)
--fin de los simbolos de las cotas
--cajas de texto
--caja de la variable b
b_v_p:move(125,4)
b_v_p:resize(35,25)
b_v_p:createMathBox()
b_v_p:registerFilter({tabKey = function() bw_v_p:setFocus() end,enterKey = function () b_v_p: setFocus(false) end})
--caja de la variable bw
bw_v_p:move(132,180)
bw_v_p:resize(35,25)
bw_v_p:createMathBox()
bw_v_p:registerFilter({tabKey = function() h_v_p:setFocus() end,enterKey = function () bw_v_p: setFocus(false) end})
--caja de la variable h
h_v_p:move(50,110)
h_v_p:resize(35,25)
h_v_p:createMathBox()
h_v_p:registerFilter({tabKey = function() hf_v_p:setFocus() end,enterKey = function () h_v_p: setFocus(false) end})
--caja de la variable hf
hf_v_p:move(240,75)
hf_v_p:resize(35,25)
hf_v_p:createMathBox()
hf_v_p:registerFilter({tabKey = function() d_v_p:setFocus() end,enterKey = function () hf_v_p: setFocus(false) end})
--caja de la variable d
d_v_p:move(240,109)
d_v_p:resize(35,25)
d_v_p:createMathBox()
d_v_p:registerFilter({tabKey = function() b_v_p:setFocus() end,enterKey = function () d_v_p: setFocus(false) end})
end
function viga_r_p(gc)
gc:drawString("Viga Interior ",20,20)
gc:setPen("medium","smooth")
gc:drawPolyLine({120,70,170,70,170,165,120,165,120,70})
gc:setPen("thin","smooth")
gc:drawRect(125,75,40,85)
gc:drawLine(160,75,150,85)
gc:drawLine(165,81,155,92)
--cotas
gc:setColorRGB(255,0,0)
--cota de b
gc:drawLine(120,170,120,180)
gc:drawLine(170,170,170,180)
gc:drawLine(120,175,170,175)
--cota de h
gc:drawLine(105,70,115,70)
gc:drawLine(105,165,115,165)
gc:drawLine(110,70,110,85)
gc:drawLine(110,150,110,165)
--cota de d
gc:drawLine(175,70,185,70)
gc:drawLine(175,155,185,155)
gc:drawLine(180,70,180,85)
gc:drawLine(180,140,180,155)
--end of cotas
--simbolos de cotas
gc:setFont("serif","i",10)
gc:setColorRGB(0,0,0)
gc:drawString(" h = cm ",25,110)
gc:drawString(" b = cm ",105,180)
gc:drawString(" d = cm ",175,110)
--fin de los simbolos de las cotas
--cajas de texto
--caja de la variable h
h_v_p:move(50,110)
h_v_p:resize(35,25)
h_v_p:createMathBox()
h_v_p:registerFilter({tabKey = function() bw_v_p:setFocus() end,enterKey = function () h_v_p: setFocus(false) end})
--caja de la variable bw
bw_v_p:move(132,180)
bw_v_p:resize(35,25)
bw_v_p:createMathBox()
bw_v_p:registerFilter({tabKey = function() d_v_p:setFocus() end,enterKey = function () b_v_p: setFocus(false) end})
--caja de la variable d
d_v_p:move(200,109)
d_v_p:resize(35,25)
d_v_p:createMathBox()
d_v_p:registerFilter({tabKey = function() h_v_p:setFocus() end,enterKey = function () d_v_p: setFocus(false) end})
end
function viga_l_l(gc)
gc:drawString("Viga Lateral",20,20)
gc:setPen("medium","smooth")
gc:drawPolyLine({120,70,205,70,205,105,170,105,170,165,120,165,120,70})
gc:setPen("thin","smooth")
gc:drawRect(125,75,40,85)
gc:drawLine(160,75,150,85)
gc:drawLine(165,81,155,92)
--simbolos de cotas
gc:setFont("serif","i",10)
gc:setColorRGB(0,0,0)
gc:drawString(" b = cm ",100,50)
gc:drawString(" h = cm ",25,110)
gc:drawString(" bw = cm ",100,180)
gc:drawString(" hf = cm ",215,75)
gc:drawString(" d = cm ",215,110)
--fin de los simbolos de las cotas
--cotas
gc:setColorRGB(255,0,0)
--cota de b
gc:drawLine(120,55,120,65)
gc:drawLine(120,60,205,60)
gc:drawLine(205,55,205,65)
--cota de bw
gc:drawLine(120,170,120,180)
gc:drawLine(170,170,170,180)
gc:drawLine(120,175,170,175)
--cota de h
gc:drawLine(105,70,115,70)
gc:drawLine(105,165,115,165)
gc:drawLine(110,70,110,85)
gc:drawLine(110,150,110,165)
--cota de d
gc:drawLine(275,70,285,70)
gc:drawLine(275,155,285,155)
gc:drawLine(280,70,280,85)
gc:drawLine(280,140,280,155)
--cota de hf
gc:drawLine(210,70,220,70)
gc:drawLine(210,105,220,105)
gc:drawLine(215,70,215,105)
--end of cotas
--cajas de texto
--caja de la variable b
b_v_l:move(125,5)
b_v_l:resize(35,25)
b_v_l:createMathBox()
b_v_l:registerFilter({tabKey = function() bw_v_l:setFocus() end,enterKey = function () b_v_l: setFocus(false) end})
--caja de la variable bw
bw_v_l:move(132,180)
bw_v_l:resize(35,25)
bw_v_l:createMathBox()
bw_v_l:registerFilter({tabKey = function() h_v_l:setFocus() end,enterKey = function () b_v_l: setFocus(false) end})
--caja de la variable h
h_v_l:move(50,110)
h_v_l:resize(35,25)
h_v_l:createMathBox()
h_v_l:registerFilter({tabKey = function() hf_v_l:setFocus() end,enterKey = function () h_v_l: setFocus(false) end})
--caja de la variable hf
hf_v_l:move(240,75)
hf_v_l:resize(35,25)
hf_v_l:createMathBox()
hf_v_l:registerFilter({tabKey = function() d_v_l:setFocus() end,enterKey = function () hf_v_l: setFocus(false) end})
--caja de la variable d
d_v_l:move(240,109)
d_v_l:resize(35,25)
d_v_l:createMathBox()
d_v_l:registerFilter({enterKey = function () d_v_l: setFocus(false) end})
end
function viga_r_l(gc)
gc:drawString("Viga Lateral",20,20)
gc:setPen("medium","smooth")
gc:drawPolyLine({120,70,170,70,170,165,120,165,120,70})
gc:setPen("thin","smooth")
gc:drawRect(125,75,40,85)
gc:drawLine(160,75,150,85)
gc:drawLine(165,81,155,92)
--cotas
gc:setColorRGB(255,0,0)
--cota de b
gc:drawLine(120,170,120,180)
gc:drawLine(170,170,170,180)
gc:drawLine(120,175,170,175)
--cota de h
gc:drawLine(105,70,115,70)
gc:drawLine(105,165,115,165)
gc:drawLine(110,70,110,85)
gc:drawLine(110,150,110,165)
--cota de d
gc:drawLine(175,70,185,70)
gc:drawLine(175,155,185,155)
gc:drawLine(180,70,180,85)
gc:drawLine(180,140,180,155)
--end of cotas
end
function on.paint(gc)
gc:setFont("sansserif","b",10)
gc:drawString("SECCION DE VIGA",85,0)
gc:setPen("medium","smooth")
gc:drawLine(82,20,205,20)
gc:setFont("sansserif","r",10)
if salida==1 or salida==2 then
--activa los cuadros de viga principal
b_v_p:setVisible(true)
bw_v_p:setVisible(true)
h_v_p:setVisible(true)
hf_v_p:setVisible(true)
d_v_p:setVisible(true)
--desactiva los cuadros de viga lateral
b_v_l:setVisible(false)
bw_v_l:setVisible(false)
h_v_l:setVisible(false)
hf_v_l:setVisible(false)
d_v_l:setVisible(false)
if salida ==1 then
viga_t_p(gc)
elseif salida==2 then
b_v_p:setVisible(false)
hf_v_p:setVisible(false)
viga_r_p(gc)
end
elseif salida==3 or salida==4 then
--activa los cuadros de viga lateral
b_v_l:setVisible(true)
bw_v_l:setVisible(true)
h_v_l:setVisible(true)
hf_v_l:setVisible(true)
d_v_l:setVisible(true)
--descativa los cuadros de viga interior
b_v_p:setVisible(false)
bw_v_p:setVisible(false)
h_v_p:setVisible(false)
hf_v_p:setVisible(false)
d_v_p:setVisible(false)
if salida==3 then
viga_l_l(gc)
elseif salida==4 then
viga_r_l(gc)
end
end
end
menu={
{"Viga Interior",
{"Viga T",function() tipo_v(1) end},
{"Viga Rectangular",function() tipo_v(2) end},
},
{"Viga Lateral",
{"Viga L",function() tipo_v(3) end},
{"Viga Rectangular",function() tipo_v(4) end}},
}toolpalette.register(menu)
soy novato en esto
-
el_mix17
Niveau 3: MH (Membre Habitué)- Messages: 10
- Inscription: 21 Mai 2015, 00:54
- Genre:
- Calculatrice(s):→ MyCalcs profile
Re: 2d.editor
You could move all the editors' move/resize/registerFilter in the
You should NOT use on.paint (or functions called from on.paint) for anything else than drawing, so those should not be in there, it will slow everything down.
on.resize
function or on.construction (that's a function only called once)You should NOT use on.paint (or functions called from on.paint) for anything else than drawing, so those should not be in there, it will slow everything down.
MyCalcs: Help the community's calculator documentations by filling out your calculators info!
MyCalcs: Aidez la communauté à documenter les calculatrices en donnant des infos sur vos calculatrices !
Inspired-Lua.org: All about TI-Nspire Lua programming (tutorials, wiki/docs...)-
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)- Messages: 14613
- Images: 1218
- Inscription: 01 Juin 2007, 00:00
- Localisation: France
- Genre:
- Calculatrice(s):→ MyCalcs profile
- Twitter/X: adriweb
- GitHub: adriweb
Re: 2d.editor
gracias por sus consejos
-
el_mix17
Niveau 3: MH (Membre Habitué)- Messages: 10
- Inscription: 21 Mai 2015, 00:54
- Genre:
- Calculatrice(s):→ MyCalcs profile
9 messages
• Page 1 sur 1
Qui est en ligne
Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 10 invités