tags:

views:

24

answers:

1

I have following matlab GUI code.

clear all;
clc;

win = figure('units','points',...
    'position',[200 250 500 400],...
    'color',[.8 .8 .8],...
    'menubar','none',...
    'resize','off',...
    'numbertitle','off',...
    'name','test window');

menu = uimenu('parent',win,...
    'Label','File');

submenu1 = uimenu('parent',menu,...
    'Label','Open');

submenu2 = uimenu('parent',menu,...
    'Label','Exit',...
    'Callback','close');

frame1 = uicontrol('parent',win,...
    'units','points',...
    'position',[30 170 200 200],...
    'backgroundcolor',[.9 .9 .9],...
    'style','Frame');

recButton = uicontrol('parent',win,...
    'units','points',...
    'position',[90 130 70 30],...
    'style','pushbutton',...
    'string','Button');

What I want to do is load an image with Open submenu (submenu1) and then display it inside frame1. I want recButton is disabled by default. After the image is loaded recButton becomes enabled. Can you help me with the code?

+2  A: 

You should first create the recButton control with its 'Enable' property set to 'off'. Then in the callback that's executed for submenu1 you should re-enable the recButton control:

set(recButton,'Enable','on');

You would just have to make sure that the handle variable recButton is available in the callback for submenu1.

gnovice
Yeah, it works. Thanks gnovice.
nata

related questions