How can I can I trigger the callback of an edit text control when setting its value from within the callback of a slider control?

4 Ansichten (letzte 30 Tage)
In a simple GUI built with GUIDE I have an edit text control and a slider control. The edit text control's callback executes properly when the user changes the control's value using the keyboard.
The purpose of the slider is also to modify the value in the edit text control. The problem I'm running into is the following:
  • User moves slider control
  • Slider control callback executes and updates the value of the text edit control:
set(handles.tx_ColorTemp, 'String', NewVal);
  • Text edit control properly displays new value "NewVal" but its callback does not execute
What am I missing? Thanks for any insight.
Xavier

Akzeptierte Antwort

Matt Fig
Matt Fig am 7 Okt. 2012
Bearbeitet: Matt Fig am 7 Okt. 2012
Editbox callbacks execute when you hit return with the cursor in the text field. You can also just set the string from the slider callback, call DRAWNOW, then call the editbox callback from the slider callback, passing the appropriate args, of course.
  1 Kommentar
Xavier
Xavier am 7 Okt. 2012
Hi Matt, thanks for the solution.
I'm not sure what is the purpose of DRAWNOW in this context as the code behaves in the same way whether I use it or not. I had tried it before, thinking that it would cause the event loop to trigger the editbox callback but that was not the case.
I've now moved the slider to a child figure and everything works fine (I have to pass a function handle for the editbox callback to the slider control and there is an extra step to retrieve the current handles structure of the parent figure when the slider callback executes but the basic idea remains the same).
Thanks again,
Xavier

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by