Update slider value after enter a value in editbox.

I have a slider that I can use to increment an editbox. However I also need to be able to enter a value in the editbox. If I enter a value in editbox and them I cick on the slider it not work properly (if before I don’t press enter). I try to update the value of the slider on the editbox callback by doing something like:
set(hslider, 'value', val);
But this don’t work properly which I believe is related with the need to add an enter after add the value to a editbox.

1 件のコメント

Ilham Hardy
Ilham Hardy 2016 年 1 月 22 日
Why you don't want to use enter button?

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

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 1 月 22 日
編集済み: Walter Roberson 2016 年 1 月 22 日

0 投票

Correct. The Callback of the Edit box is not invoked until an enter is received.

6 件のコメント

Armindo
Armindo 2016 年 1 月 22 日
But there is now way to update the slider? Or programmatically add an enter?
Stephen23
Stephen23 2016 年 1 月 22 日
編集済み: Stephen23 2016 年 1 月 22 日
Take a look at my FEX submission "Regular Expression Helper", it uses the key-press function to update strings used in regexp (and displays the output). This would be easy to adapt to update a slider value.
Armindo
Armindo 2016 年 1 月 22 日
Thank you Walter and Stephen. In fact I have been looking to the example of Matt Fig (using keypress) reported here: http://www.mathworks.com/matlabcentral/answers/8921-pull-string-out-of-edit-text-without-user-hitting-enter
Which is similar to what Stephen was suggesting. However until now I was unable to update the slider properlly.
The is any chance that you can show me and example about how to perform this?
Thank you for the help .
Walter Roberson
Walter Roberson 2016 年 1 月 22 日
The problem with using the KeyPressFcn is that you do not know whether the user is finished typing unless you see the user type a particular character such as return.
Armindo
Armindo 2016 年 1 月 26 日
Yes indeed. That is a big issue. Thank you for all the help.

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

質問済み:

2016 年 1 月 21 日

コメント済み:

2016 年 1 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by