Question

I have these callback functions:

function q7_OpeningFcn(hObject, eventdata, handles, varargin)

-----
-----
function column_icrement_Callback(hObject, eventdata, handles)

----
----

function row_icrement_Callback(hObject, eventdata, handles)
----
----

function width_increment_Callback(hObject, eventdata, handles)
---
---

These are the last 3 functions that I want to send parameters to from function q7_OpeningFcn(hObject, eventdata, handles, varargin). I have successfully loaded the picture but I am not sure whether I can send more than 3 parameters or not for adjusting row,col, height, width?

Was it helpful?

Solution

Do NOT use global variables. Use the handles structure to pass this data.

In q7_OpeningFcn, store this data (e.g. handles.rows=...).

In the callbacks, you will have the data in the handles struct.

If you change values in handles in your callbacks, you need to run guidata(hObject,handles). See Store Data Using the guidata Function and the example there.

You can also use setappdata/getappdata to store and retrieve data by name ("application data"). See the article Share Data Among Callbacks for details on both approaches.

Even more on storing data in a GUI.

OTHER TIPS

define global variables.
http://www.mathworks.com/help/matlab/ref/global.html

in summary: put global row, col, ... at the beginning of q7_OpeningFcn. then in each function that is in charge of one of those variables put global row=value in that function.

for example:

function q7_OpeningFcn(hObject, eventdata, handles)
    global column, row, width
    doStuff 
end

function column_icrement_Callback(hObject, eventdata, handles)
    global column
    column=value
end

function row_icrement_Callback(hObject, eventdata, handles)
    global row
    row=value
end

function width_increment_Callback(hObject, eventdata, handles)
    global width
    width=value
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top