フィルターのクリア

Display default variable in edit box that can be modified in GUI

2 ビュー (過去 30 日間)
Christine Abou Nasr
Christine Abou Nasr 2017 年 6 月 2 日
編集済み: Christine Abou Nasr 2017 年 6 月 6 日
Hello! I have an edit box that is linked to a popmenu. For example, if I select parameter1 in the popmenu, the editbox displays a default value value1. If parameter2 is selected in the popmenu, value2 is displayed in the editbox. The unit is also displayed in another textbox as shown in the image below. I also need that all the default values in the editbox can be modified and appear in the workspace to be used later.
This is my code:
function param_menu_Callback(hObject, eventdata, handles)
global parametre
parametre=get(handles.param_menu, 'Value');
if parametre==1
set(handles.edit_vmin, 'String' , '----');
set(handles.unit_text, 'String', {''}); % sets the units in the unit_text
elseif parametre==2
set(handles.edit_vmin, 'String' , '1000'); %sets filtering values of the chosen parameter
set(handles.unit_text, 'String', {'Tours/s'}); % sets the units in the unit_text
elseif parametre==3
set(handles.edit_vmin, 'String', '100');
set(handles.unit_text, 'String', {'kW'});
elseif parametre==4
set(handles.edit_vmin, 'String', '9.5');
set(handles.unit_text, 'String', {'Tours/s'});
elseif parametre==5
set(handles.edit_vmin, 'String', '5');
set(handles.unit_text, 'String', {'m/s'});
end
function edit_vmin_Callback(hObject, eventdata, handles)
global valeur_min
valeur_min=str2double(get(handles.edit_vmin,'String'));
It gives me "value_min" in the workspace (double) (that i can use in another file).
When I change the value (remove the default value of editbox and choose another one)and start the analysis, the value goes back to the default value and not the one i've entered. I would like to be able to have a default value and to still be able to choose one. Thank you again for your time!
  6 件のコメント
Adam
Adam 2017 年 6 月 6 日
Do you press enter or tab or something similar after editing the value? An edit callback won't trigger if you just type the number in. I'm not sure if it would trigger before the pushbutton callback if you move away and click on that, I assume not.
Christine Abou Nasr
Christine Abou Nasr 2017 年 6 月 6 日
編集済み: Christine Abou Nasr 2017 年 6 月 6 日
I solved the problem with this:
function update_date_button_Callback(hObject, eventdata, handles)
%edit_vmin_Callback(handles.edit_vmin, [], handles)
param_menu_Callback(handles.param_menu, [], handles)
set(handles.edit_vmin,'String', handles.valeur_min);

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by