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?

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

 채택된 답변

Matt Fig
Matt Fig 2012년 10월 7일
편집: Matt Fig 2012년 10월 7일
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

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품

질문:

2012년 10월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by