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

3 ビュー (過去 30 日間)
LO
LO 2020 年 7 月 3 日
コメント済み: LO 2020 年 7 月 6 日
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);

採用された回答

Vimal Rathod
Vimal Rathod 2020 年 7 月 6 日
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 件のコメント
LO
LO 2020 年 7 月 6 日
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

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSystem Commands についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by