Hello MatLabers
I am looking for a better/smoother way to implement the setting of a class variable in a callback. I'm sure there is a nicer method than what I'm doing right now.
I have a class property called "displayMode" that has its own set method in the class (function set.displayMode(obj, val)...). On a contextmenu callback I would like to change that value.
function enableView(this, value, varargin)
this.displayMode = value;
end
en3D = @(h,e)enableView(this,'3D');
en2D = @(h,e)enableView(this,'Frame');
this.mycontextmenu = uicontextmenu;
item1 = uimenu(this.mycontextmenu,'Label','...', 'Callback', ...
item2 = uimenu(this.mycontextmenu,'Label','3D view','Callback',en3D);
item3 = uimenu(this.mycontextmenu,'Label','2D view','Callback',en2D);
..
I'm looking for a possibility that avoids the additional function (here: enableView(...)). I'm thinking of something like:
hSet3D = ['set(this, ''displayMode'', ''3D'')'];
item3 = uimenu(this.mycontextmenu,'Label','better','Callback',hSet3D);
but I can not access the object itself here (this).
Thanks!