Is there a existing way to get access to a class instance structure while having access only to the object handle??

2 Ansichten (letzte 30 Tage)
Hello, I am new to OOP, GUI's and Matlab. With that upfront, I am developing a GUI using classes I've developed. I have a callback routine like this:
set(ebDx.eBx,'Callback',{@ebDx_Callback,handles});
...
...
[end of main]
function ebDx_Callback(objH,~,handles)
objH.classMethod % this crashes... I am assigning a field to a struct
My question: is there an easy way to get access to the structure for which objH is the handle (a double).
  1 Kommentar
Walter Roberson
Walter Roberson am 29 Mär. 2013
Is ebDx.eBx a handle to an edit box, or a handle to a class? If it is a handle to a class, then how is the Callback getting activated? If it is a handle to an edit box, then where does the class come into this?

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Sean de Wolski
Sean de Wolski am 29 Mär. 2013
s = get(objH) %?
Perhaps you could show a minimal class that throws the error. Also, have you seen Steve's blog on GUIs made with classes?
  2 Kommentare
David Conway
David Conway am 29 Mär. 2013
Sean,
Thanks for the quick response. However, I have tried that. That function returns the properties associated with the graphics object, edit box, in this case, and not the structure variable associated with the class instance: tag, value, string, etc.
Sean de Wolski
Sean de Wolski am 29 Mär. 2013
Huh, I'm not clear? Please provide a minimal working example. Perhaps a simple class with one figure and editbox.

Melden Sie sich an, um zu kommentieren.


Darik
Darik am 29 Mär. 2013
It looks to me like ebDx is a handle object, and ebDx.eBx is a uicontrol handle? (Those are awful variable names, by the way)
If that's the case, you want something like
set(ebDx.eBx,'Callback',@(uicontrol_handle, event)ebDx_Callback(ebDx, uicontrol_handle, event, handles))
function ebDx_Callback(object_handle, uicontrol_handle, ~,handles)
object_handle.classMethod (...)

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by