Thread Subject: Setting uicontrol callbacks outside of the main gui .m file

Subject: Setting uicontrol callbacks outside of the main gui .m file

From: Daniel

Date: 23 Jun, 2008 22:07:02

Message: 1 of 3

I have a dynamic GUI that creates/destroys components at
runtime. I have written a class in a separate file to create
and set the properties of new uicontrols. I'm trying to set
the callbacks for the uicontrol, but I am having trouble
setting the callback function, which is located in the main
gui file, similar to a GUIDE .m file, where other callbacks
(for static uicontrols) are generated automatically.

Imagine this: I have a class 'myclass' that contains the
necessary information to generate some uicontrols. I also
have the main gui.m file that initializes the gui, and
passes a parent panel to a member function of myclass. The
member function generates some children uicontrols, modifies
their properties, assigns them to the parent panel, and
returns control to gui.m. Everything works except assigning
a callback, since the callback is located in the GUI file.

So my question is this: can it be done? What are some
suggestions for syntax to do this? Must I somehow specify
where the callback function is located?

Subject: Setting uicontrol callbacks outside of the main gui .m file

From: Daniel

Date: 24 Jun, 2008 14:13:02

Message: 2 of 3

Any ideas? I'm still lost on this one.

Subject: Setting uicontrol callbacks outside of the main gui .m file

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 24 Jun, 2008 15:52:16

Message: 3 of 3

In article <g3p6q5$8dc$1@fred.mathworks.com>,
Daniel <anothermathgeek+matlab@gmail.com> wrote:
>I have a dynamic GUI that creates/destroys components at
>runtime. I have written a class in a separate file to create
>and set the properties of new uicontrols. I'm trying to set
>the callbacks for the uicontrol, but I am having trouble
>setting the callback function, which is located in the main
>gui file, similar to a GUIDE .m file, where other callbacks
>(for static uicontrols) are generated automatically.

>Imagine this: I have a class 'myclass' that contains the
>necessary information to generate some uicontrols. I also
>have the main gui.m file that initializes the gui, and
>passes a parent panel to a member function of myclass. The
>member function generates some children uicontrols, modifies
>their properties, assigns them to the parent panel, and
>returns control to gui.m. Everything works except assigning
>a callback, since the callback is located in the GUI file.

>So my question is this: can it be done? What are some
>suggestions for syntax to do this? Must I somehow specify
>where the callback function is located?

In order for a routine to set a function as a callback to a control,
the function must be the main file of a .m file on the path,
or the routine setting the callback must -somehow- have obtained
a handle to the function. It is not possible for B.m to set sub-function
Z of A.m as a callback unless B has access to a handle to Z.
--
  "The whole history of civilization is strewn with creeds and
  institutions which were invaluable at first, and deadly
  afterwards." -- Walter Bagehot

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
callback function Daniel 23 Jun, 2008 18:10:21
callback Daniel 23 Jun, 2008 18:10:21
dynamic gui Daniel 23 Jun, 2008 18:10:21
rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com