How to activate the code in a callback from a push button in one GUI from another pushbutton from the other GUI?

6 ビュー (過去 30 日間)
Jacob Schoeb
Jacob Schoeb 2017 年 4 月 15 日
編集済み: Sindhu Priya 2017 年 4 月 21 日
Basically, I am doing a delete confirmation pop-up window (not menu uicontrol) when another GUI's delete push button is pressed. What I want is for when the delete button on the regular GUI is pressed, another delete confirmation window is popped up( I understand how to get the pop up window to show up). With that GUI, if the delete pushbutton is clicked, then I want the code to run for the callback for the delete button of the original GUI.

回答 (1 件)

Sindhu Priya
Sindhu Priya 2017 年 4 月 21 日
編集済み: Sindhu Priya 2017 年 4 月 21 日
Hi Jacob,
As you are trying to give a pop-up when delete button is pushed, the callback function of the delete button would have been set to creating the pop-up. So, as far as I understand, calling the delete button callback from the pop-up menu will cause a recursive call.
I am posting a relevant example. Please have a look at the following code snippet.
function choice = choosedialog
d = figure('Position',[300 300 250 150],'Name','Select One');
popup = uicontrol('Parent',d,...
'Style','pushbutton',...
'Position',[75 70 100 25],...
'String',{'Delete'},...
'Callback',@popup_callback);
% Wait for d to close before running to completion
uiwait(d);
function popup_callback(popup,event)
choice = questdlg('Would you like to delete ?', ...
'Choice',...
'Yes','No','No');
% Handle response
switch choice
case 'Yes'
disp([choice ' choosen.'])
delete(gcf);
case 'No'
disp([choice ' choosen.'])
end
end
end
Hope this answers your query.
Regards,
Sindhu

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by