How to set visible off in pushbutton after clicking.
9 views (last 30 days)
Show older comments
After clicking play button then it will disappear.
function [] = main ()
figure('name','CROSSWORD PUZZLE','MenuBar','none','Color',[.7,.78,1],'units','normalized','outerposition',[0 0 .5 .8]')
Title='CROSSWORD';
a=1;
for x=20:30:260
tagn=strcat('TBox',num2str(a));
uicontrol('Style','edit','position',[x, 530, 30, 30],'String',Title(a),'FontSize',20,'Tag',tagn)
a=a+1;
end
TitleB='PUZZLE';
a=1;
for x=80:30:230
tagn=strcat('TBox1',num2str(a));
uicontrol('Style','edit','position',[x, 500, 30, 30],'String',TitleB(a),'FontSize',20,'Tag',tagn)
a=a+1;
end
S.pb = uicontrol('Style','pushbutton','Position',[500 350 60 30],'String','PLAY');
set(S.pb,'callback',{@game,S})
S.ob = uicontrol('Style','pushbutton','Position',[500 300 60 30],'String','OPTION');
set(S.ob,'callback',{@set,S})
function [] = game(varargin)
for x=20:30:620
for y=420:-30:30
uicontrol('Style','edit','position',[x y 30 30],'FontSize',20)
end
end
0 Comments
Accepted Answer
Geoff Hayes
on 13 Sep 2015
Ariel - you've assigned the following callback to the PLAY button
function [] = game(varargin)
with a variable list of input arguments, varargin. I see also that when you set the callback, you pass an additional parameter, S, which is a structure that has the handles to the graphics objects. This seems to be similar to what GUIDE would do when it creates a callback with the third parameter being the handles structure. What this means, is that your callback could then be written as
function [] = game(hObject, eventdata, handles)
where hObject is the handle to the play button graphics object and eventdata an empty matrix. So if you wish to set the visible flag for this button when you press it, you could do the following
function [] = game(hObject, eventdata, handles)
set(hObject,'Visible','off');
% etc.
Note that the S is not like the usual handles structure (from GUIDE) since you don't (yet) have a mechanism to pass an updated it version of it each time the callback fires. So you could remove it and just assign and set the callback as
set(S.pb,'callback',@game)
with
function game(hObject, eventdata)
More Answers (0)
See Also
Categories
Find more on Graphics Object Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!