π
<-

2d.editor

Pour TI-Nspire OS 3.0 ou ultérieur.

2d.editor

Unread postby el_mix17 » 19 Nov 2015, 00:53

help !! getFormattedExpression() ?????? 2d.editor parameter ???
User avatar
el_mix17
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 92%
 
Posts: 10
Joined: 21 May 2015, 00:54
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: 2d.editor

Unread postby Adriweb » 19 Nov 2015, 01:06

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...)
My calculator programs
Mes programmes pour calculatrices
User avatar
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 79.9%
 
Posts: 14837
Images: 1131
Joined: 01 Jun 2007, 00:00
Location: France
Gender: Male
Calculator(s):
MyCalcs profile
Twitter: adriweb
GitHub: adriweb

Re: 2d.editor

Unread postby el_mix17 » 19 Nov 2015, 03:25

Help me get the numerical value of a text box to use mathematics in var.store and use that value in another application

ayuda

Image Image

Code: Select all
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
User avatar
el_mix17
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 92%
 
Posts: 10
Joined: 21 May 2015, 00:54
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: 2d.editor

Unread postby Adriweb » 19 Nov 2015, 03:35

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
Code: Select all
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...)
My calculator programs
Mes programmes pour calculatrices
User avatar
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 79.9%
 
Posts: 14837
Images: 1131
Joined: 01 Jun 2007, 00:00
Location: France
Gender: Male
Calculator(s):
MyCalcs profile
Twitter: adriweb
GitHub: adriweb

Re: 2d.editor

Unread postby el_mix17 » 19 Nov 2015, 03:45

gracias... otra pregunta




Image comando ???
User avatar
el_mix17
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 92%
 
Posts: 10
Joined: 21 May 2015, 00:54
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: 2d.editor

Unread postby Adriweb » 19 Nov 2015, 03:52

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...)
My calculator programs
Mes programmes pour calculatrices
User avatar
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 79.9%
 
Posts: 14837
Images: 1131
Joined: 01 Jun 2007, 00:00
Location: France
Gender: Male
Calculator(s):
MyCalcs profile
Twitter: adriweb
GitHub: adriweb

Re: 2d.editor

Unread postby el_mix17 » 19 Nov 2015, 03:59

gracias por sus respuestas :) :) :)
me podría dar algún consejo de como estructurar este código ??
Code: Select all
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)




Image

soy novato en esto :( :( :(
User avatar
el_mix17
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 92%
 
Posts: 10
Joined: 21 May 2015, 00:54
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: 2d.editor

Unread postby Adriweb » 19 Nov 2015, 04:13

You could move all the editors' move/resize/registerFilter in the 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...)
My calculator programs
Mes programmes pour calculatrices
User avatar
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 79.9%
 
Posts: 14837
Images: 1131
Joined: 01 Jun 2007, 00:00
Location: France
Gender: Male
Calculator(s):
MyCalcs profile
Twitter: adriweb
GitHub: adriweb

Re: 2d.editor

Unread postby el_mix17 » 19 Nov 2015, 12:46

gracias por sus consejos :)
User avatar
el_mix17
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 92%
 
Posts: 10
Joined: 21 May 2015, 00:54
Gender: Not specified
Calculator(s):
MyCalcs profile


Return to Nspire-Lua

Who is online

Users browsing this forum: No registered users and 1 guest

-
Search
-
Social TI-Planet
-
Featured topics
Comparaisons des meilleurs prix pour acheter sa calculatrice !
"1 calculatrice pour tous", le programme solidaire de Texas Instruments. Reçois gratuitement et sans aucune obligation d'achat, 5 calculatrices couleur programmables en Python à donner aux élèves les plus nécessiteux de ton lycée. Tu peux recevoir au choix 5 TI-82 Advanced Edition Python ou bien 5 TI-83 Premium CE Edition Python.
Enseignant(e), reçois gratuitement 1 exemplaire de test de la TI-82 Advanced Edition Python. À demander d'ici le 31 décembre 2024.
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
1234
-
Donations / Premium
For more contests, prizes, reviews, helping us pay the server and domains...
Donate
Discover the the advantages of a donor account !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partner and ad
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
1237 utilisateurs:
>1180 invités
>49 membres
>8 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Other interesting websites
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)