How to get the new value of a changed mask parameter in the dialog callback?

조회 수: 11 (최근 30일)
Hello, I am using Matlab R2011a. I have created a subsystem and masked it. There is a popup parameter in my mask and I have added a dialog callback to handle some things when the user changes the popup selection. At the moment, it seems as if in the dialog callback, when getting the value of the popup parameter with get_param(gcb,<parametername>), the old value is returned. Is there a way to get the current value of it?
Thank you,
Christian

채택된 답변

Kaustubha Govind
Kaustubha Govind 2013년 5월 29일
I think you need to just use the 'parametername' directly since it exists as a variable in the Mask workspace. Does that work?
  댓글 수: 8
Kaustubha Govind
Kaustubha Govind 2013년 6월 14일
Christian: It looks like the Open callback is creating a new dialog (using DAStudio.Dialog). You can see this by running the same code from the command window on let's say, a Constant block in a model. You'll see that dlg.show opens a dialog, but when you double-click on the Constant block, there is a second dialog window opened. So, essentially, it is physically separate from the Mask dialog, which is why the callback is not getting the right values. I'm not sure how this new dialog interacts with the Mask dialog and invokes the right callback though. I think this problem is beyond my expertise, so I would recommend waiting to see what Tech Support recommends.
Christian
Christian 2013년 6월 14일
Thank you for mentioning that the Open Callbacks opens another instance of the mask dialog. This is correct and it brought me to a solution finally:
t = DAStudio.ToolRoot;
dv = t.getOpenDialogs;
value = dv(1).getWidgetValue('Parameter1')
This will give me the current value of param1. The argument passed to getWidgetValue is NOT the name of the mask variable, but the prompt of it, as defined in the mask. Thanks a lot for your support.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Author Block Masks에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by