0

I am currently programming a GUI to display information for a robotic hand and when I right click any of the components in this GUI I cannot seem to find the Callback function. I have made a few other GUIs and I have not come across this problem before and I can't seem to find anyone with the same problem on Google.

Here is an example of what I mean:

enter image description here

Does anyone know how to fix this?

Amro
  • 123,847
  • 25
  • 243
  • 454
jlcv
  • 1,688
  • 5
  • 21
  • 50
  • I don't know what you mean. What do you mean by "callback"? – David Heffernan Jun 01 '13 at 21:13
  • Can you post an image of the one you can't find the callback(s)? – p8me Jun 01 '13 at 21:15
  • So what's special about the project that doesn't behave as expected? – David Heffernan Jun 01 '13 at 21:19
  • @pm89 The image in this question is the one with the missing Callback, there is not option from the drop down list. There is no code for the function either. – jlcv Jun 01 '13 at 21:20
  • @DavidHeffernan I'd like to edit the graphs, ie. f2_acceleration, but there is no Callback function for me to do this. – jlcv Jun 01 '13 at 21:21
  • 1
    Who said that a graph object should have a "Callback" function? – Eitan T Jun 01 '13 at 21:26
  • 1
    I agree with @EitanT. If you explain what you want to do in your Callback function we might be able to help, or what event callback do you need? – p8me Jun 01 '13 at 21:30
  • @EitanT Hmm, I think you might be right, does that mean I have to edit all of them in the OpeningFcn? Or can I create a new function to edit the graphs? Just that I have been coding buttons, etc, inside their Callback functions and thought that every component would have this. – jlcv Jun 01 '13 at 21:32

1 Answers1

4

The three callbacks you see (ButtonDownFcn, CreateFcn and DeleteFcn) are the three callback functions that all graphical objects share in MATLAB. The Callback callback is something unique to active interface objects, such as a button.

A callback function is invoked when the associated event occurs for that object. The code that you put into the callback depends on what you want it to do. Do you want your graph to respond to left mouse clicks? Then code into ButtonDownFcn. Do you want it to respond to something else? Choose the appropriate callback instead.

Read more about it here...

Eitan T
  • 32,660
  • 14
  • 72
  • 109
  • 1
    Thanks, this makes a lot of sense. I have one more question, I noticed that when I clicked CreateFcn, a new function such as text12_CreateFcn would be created in MATLAB. But when I try to delete this new function and run the GUI I get the error "Error using feval. Undefined function 'text12_CreateFcn' for input arguments of type 'double'.". Are you familiar with this? – jlcv Jun 01 '13 at 21:43
  • 1
    The `CreateFcn` is invoked upon initialization of the object. You shouldn't be deleting it if the object still exists, just leave it empty. – Eitan T Jun 01 '13 at 21:47
  • Alright, but when I change the "Tag" property of the component, the name for CreateFcn does not change. Is this normal? – jlcv Jun 01 '13 at 21:49
  • `CreateFcn` is a fixed name for that property and cannot be changed. You can code into that function, if you need to initialize anything specific before that object is displayed on screen. – Eitan T Jun 01 '13 at 21:52
  • Sorry, I meant the name in front of `CreateFcn`. Is it possible to change `text12_CreateFcn` to `hello_CreateFcn`? – jlcv Jun 01 '13 at 21:54
  • 1
    Should be possible. The `Tag` property has nothing to do with the `CreateFcn`. – Eitan T Jun 01 '13 at 21:59