Quantcast
Channel: Indigo Rose Software Forums - Forums
Viewing all articles
Browse latest Browse all 2105

Input formatting and receive input

$
0
0
Hi
Please see attached GIF to see code in action!

Basically you put number in input (either by typing o pasting) and it automatically gets comma " , " for decimal or " ' " apostrophe for million. It all works great.

The thing is, I cannot prevent users from typing characters (e.g. a, b, c..etc).

Of course I can enable Input mask and set it to: #########. That would limit users to type only numbers up to 999'000,000...which is great but....at the same time, whatever code is in On Char is ignored and what you see in GIF no longer works.

So, can I have both? input formatting (input mask) and code recognised in On Char?

Thanks!

Here is code within On Char


Code:
local NumeroSinPuntuacion
local CantFinal

local SearchCliente = Input.GetText("inp_Cantidad");

local BuscaMillon = String.Find(SearchCliente, "'", 1, false);


if BuscaMillon ~= -1 then --si es que encuentra el signo de millon entonces se sobreentiende que tambien existe el signo de coma decimal, asi que ambos seran reemplazados por "" es decir ambos signos seran removidos

NumeroSinPuntuacion = String.Replace( String.Replace(SearchCliente, "'", "", false) ,",", "", false );

else --si no encuentra el signo de millon, entonces buscará el signo de coma decimal, si es que lo encuentra, lo remueve

local BuscaComa = String.Find(SearchCliente, ",", 1, false);

if BuscaComa ~= -1 then

NumeroSinPuntuacion = String.Replace(SearchCliente, ",", "", false);

else --si tampoco encuentra coma decimal, entonces no hace nada

NumeroSinPuntuacion = SearchCliente

end
end



local saberLength = String.Length(NumeroSinPuntuacion);
local e_Char = saberLength

if e_Char > 3 and e_Char < 7 then

local LosNumerosAntesDeComa = String.Left(NumeroSinPuntuacion, e_Char-3);
local LosNumerosDespuesComa = String.Right(NumeroSinPuntuacion, 3);

CantFinal = LosNumerosAntesDeComa..","..LosNumerosDespuesComa
Input.SetText("inp_Cantidad", CantFinal);

local saberLength2 = String.Length(CantFinal);

Input.SetSelection("inp_Cantidad", saberLength2 + 1, saberLength2 + 1); -- con esto sitúo el cursor al final del input para que los números que tipeen se añadan al final, de lo contrario los numeros que se tipeen aparecerian al inicio del input

elseif e_Char >= 7 then
local LosNumerosAntesDeComaMILLON = String.Left(NumeroSinPuntuacion, e_Char-6);
local LosNumerosDespuesComaMILES = String.Right(NumeroSinPuntuacion, 3);
local LosNumerosMedios = String.Mid(NumeroSinPuntuacion, (e_Char-6) + 1, 3);

CantFinal = LosNumerosAntesDeComaMILLON.."'"..LosNumerosMedios ..","..LosNumerosDespuesComaMILES
Input.SetText("inp_Cantidad", CantFinal);

local saberLength2 = String.Length(CantFinal);

Input.SetSelection("inp_Cantidad", saberLength2 + 1, saberLength2 + 1); -- con esto sitúo el cursor al final del input para que los números que tipeen se añadan al final, de lo contrario los numeros que se tipeen aparecerian al inicio del input

elseif e_Char <= 3 then

CantFinal = NumeroSinPuntuacion

end


local cualSelecc = XamlListBox.GetSelectedItem("SampleLB");

if cualSelecc ~= -1 then

XamlListBox.SetUpdate("SampleLB", false);

local elTextData = XamlListBox.GetItemData("SampleLB", cualSelecc);
local elTextDataEX = XamlListBox.GetItemDataEx("SampleLB", cualSelecc);

local tbl_Info = AE.StringDelimitedToTable(elTextData, ";");

local s = string.format(strXamlSample1,elTextDataEX, CantFinal, tbl_Info[3], tbl_Info[4])
XamlListBox.SetItemText("SampleLB", cualSelecc, s)
XamlListBox.SetItemData("SampleLB", cualSelecc, tbl_Info[1]..";"..SearchCliente..";"..tbl_Info[3]..";"..tbl_Info[4]..";"..tbl_Info[5]);

XamlListBox.SetUpdate("SampleLB", true);

end



https://ibb.co/wQ6f7GW

Viewing all articles
Browse latest Browse all 2105

Trending Articles