Thread Subject: How to activate other callbacks only when a pushbutton is clicked?

Subject: How to activate other callbacks only when a pushbutton is clicked?

From: Rachel Laughs

Date: 6 Nov, 2009 21:12:02

Message: 1 of 3

I am creating my first GUI in MATLAB. I prefer to do this programmatically.

I have an initial figure/panel/menu thing set up with 3 interactive components:
1. user is asked to enter in a filename, which will be loaded
2. user is asked to select an item from a pop-up menu
3. OK button to confirm choices and move on (aka intialize callbacks of parts 1 and 2)


a) How do you associate the callbacks of the first two parts to the third, so that only when the "OK" button is pushed does the other callbacks occur?

I tried to do this as 2 functions embedded in the push-button function, but I get the error "undefined function or method...for input arguments" which I am assuming is because this type of subfunction isn't allowed.

b) How do I take the entered string value from the edit uicontrol box (component 1) and have the callback function load this as a file?

When I start messing with callbacks, I have really no clue what is going on. I might also be grossly misunderstanding the entire concept of them! I have read the supplied docs, and thought I understood, but really failed when trying to write my code.

c) Also: in an application example in the GUI docs ("simple_gui_2"), there is a portion that says:

      function popup_menu_Callback(source,eventdata)
         % Determine the selected data set.
         str = get(source, 'String');
         val = get(source,'Value');
         % Set current data to the selected data set.
         switch str{val};

now, what is this "(source,eventdata)" business going on in the code? "source" and "eventdata" don't appear to be defined/used anywhere else. I tried searching in the Help and it did not make sense to me. Any more-plain-English explanations would be greatly appreciated!

I apologize if a similar thread has already been resolved and I just didn't come across it. Please feel free to link me to any other relevant threads. Thank you very much!!

Subject: How to activate other callbacks only when a pushbutton is

From: Nathan

Date: 6 Nov, 2009 21:18:53

Message: 2 of 3

On Nov 6, 1:12 pm, "Rachel Laughs" <remove.thisrachellau...@gmail.com>
wrote:
> I am creating my first GUI in MATLAB. I prefer to do this programmatically.
>
> I have an initial figure/panel/menu thing set up with 3 interactive components:
> 1. user is asked to enter in a filename, which will be loaded
> 2. user is asked to select an item from a pop-up menu
> 3. OK button to confirm choices and move on (aka intialize callbacks of parts 1 and 2)
>
> a) How do you associate the callbacks of the first two parts to the third, so that only when the "OK" button is pushed does the other callbacks occur?
>
> I tried to do this as 2 functions embedded in the push-button function, but I get the error "undefined function or method...for input arguments" which I am assuming is because this type of subfunction isn't allowed.  
>
> b) How do I take the entered string value from the edit uicontrol box (component 1) and have the callback function load this as a file?
>
> When I start messing with callbacks, I have really no clue what is going on.  I might also be grossly misunderstanding the entire concept of them!  I have read the supplied docs, and thought I understood, but really failed when trying to write my code.
>
> c) Also: in an application example in the GUI docs ("simple_gui_2"), there is a portion that says:
>
>       function popup_menu_Callback(source,eventdata)
>          % Determine the selected data set.
>          str = get(source, 'String');
>          val = get(source,'Value');
>          % Set current data to the selected data set.
>          switch str{val};
>
> now, what is this "(source,eventdata)" business going on in the code? "source" and "eventdata" don't appear to be defined/used anywhere else.  I tried searching in the Help and it did not make sense to me. Any more-plain-English explanations would be greatly appreciated!
>
> I apologize if a similar thread has already been resolved and I just didn't come across it. Please feel free to link me to any other relevant threads. Thank you very much!!

I can't be of much help here other than pointing you to a set of
programmable gui examples submitted by Matt Fig:
http://www.mathworks.com/matlabcentral/fileexchange/24861-35-complete-gui-examples

Good luck. I'm sure there is plenty you will learn from those.

-Nathan

Subject: How to activate other callbacks only when a pushbutton is

From: Rachel Laughs

Date: 6 Nov, 2009 21:25:04

Message: 3 of 3

Nathan <ngreco32@gmail.com> wrote in message <1b27c717-b522-4a38-b724-3dcb74f03959@13g2000prl.googlegroups.com>...
>
> I can't be of much help here other than pointing you to a set of
> programmable gui examples submitted by Matt Fig:
> http://www.mathworks.com/matlabcentral/fileexchange/24861-35-complete-gui-examples
>
> Good luck. I'm sure there is plenty you will learn from those.
>
> -Nathan


Thanks for the quick response! and Wow, what a treasure chest of examples! I had been having trouble finding suitable examples all day, so resorted to posting here. I had even been hoping that the infamous Matt Fig could provide some feedback for me, so I'm sure you are correct in that I will learn a lot from that link.

Thanks again!

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
gui Rachel Laughs 6 Nov, 2009 16:14:07
callbacks Rachel Laughs 6 Nov, 2009 16:14:07
multiple callbacks Rachel Laughs 6 Nov, 2009 16:14:07
popup menu Rachel Laughs 6 Nov, 2009 16:14:07
pushbutton Rachel Laughs 6 Nov, 2009 16:14:07
edit Rachel Laughs 6 Nov, 2009 16:14:07
source Rachel Laughs 6 Nov, 2009 16:14:07
eventdata Rachel Laughs 6 Nov, 2009 16:14:07
rssFeed for this Thread
 

MATLAB Central Terms of Use

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 Terms prior to use.

Contact us at files@mathworks.com