how can I set spinner limit range based on text box entry ?

7 visualizaciones (últimos 30 días)
LO
LO el 3 de Jul. de 2020
Comentada: LO el 6 de Jul. de 2020
I have a gui with a spinner in it
I would like to input a value in a text box and use it as upper limit for the spinner
can't find a way to do it. It seems the function does not read the text entry
here is my code for the text box
function RECdurationminTextAreaValueChanged(app, event)
REC = app.RECdurationminTextArea.Value;
app.selectminuteSpinner.Limits = [0 REC];
end
and here for the spinner
function selectminuteSpinnerValueChanged(app, event)
value = app.selectminuteSpinner.Value;
end
however when I run it I get this error when I try to scroll the spinner up or down:
Error using matlab.ui.control.internal.model.PropertyHandling.validateLimitsInput (line 721)
'Limits' must be a 1-by-2 increasing array of real numbers, such as [0 100]. Use -Inf and/or Inf to indicate no bound for the lower and/or upper limit.
Error in matlab.ui.control.internal.model.AbstractNumericComponent/set.Limits (line 225)
rowVectorLimits = matlab.ui.control.internal.model.PropertyHandling.validateLimitsInput(obj, newValue);

Respuesta aceptada

Vimal Rathod
Vimal Rathod el 6 de Jul. de 2020
Hi,
Firstly you could check if your text box returns which type of data. The value you get from a normal textbox is a char or string value unless it is a numerical textbox. Try using "str2double" function before assigning the spinner limits.
REC = app.RECdurationminTextArea.Value;
% assign 2nd index(Upper Limit) of limits.
app.selectminuteSpinner.Limits(2) = str2double(REC); %str2double
Refer to the following link to know more about numeric edit field
  1 comentario
LO
LO el 6 de Jul. de 2020
Thanks Vimal
in fact I was using a non numeric editor
however the trouble of the spinner now is another: it lags behind so I cannot use the "last number displayed" by the spinner but only the one before. which makes it impossible to use the spinner value bidirecetionally and with accuracy. At least according to what I understood so far
Thanks though

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by