Tuesday, 6 August 2013

How to restrict findobj to only find object in gui being currently created?

How to restrict findobj to only find object in gui being currently created?

I have two guis which are exact copies of each other. However only some of
the functionality is used in each gui. I basically saved a monolithic gui
in GUIDE under two different names. I am dividing up the monolith into
subguis, each with the same fig file but saved in GUIDE with different
names. SubguiA and subguiB are launched from two buttons on a parent gui.
In each subgui there is a usercontrol(a panel) which has 'UserData' set to
3005.I run subguiA from button 1. I run subguiB from button2 and step in
and ask for hpanel = findobj('UserData',3005) from within the CreateFcn of
one of the textboxes on the subguiB. I get back hpanel as 2x1 double
because it finds two such panels in memory. I get that. So then when I go
to set the userdata of the textbox using hpanel as 'Parent', the app
crashes because hpanel is supposed to be 1x1. I thought I would use the
handle of the subguiB in findobj so that is specifically restricts findobj
to subguiB. However when the CreateFcn of the textbox on subguiB is being
run, it does not yet have the hObject of the entire subguiB. The hObject
of the entire subguiB is available from the OpeningFcn of the subguiB,
which runs only after the CreateFcns of all the usercontrols on it have
executed. So the question is: how do I restrict findObj to finding the
object only in subguiB( which is currently being created?). thanks

No comments:

Post a Comment