Bonjour,
Dans le code suivant, un push button est muni d'un callback devant renvoyer sur une fonction (publique) de l'objet mère qui contient un handle vers le pushbutton. Malheureusement, cette fonction n'est pas visible par le push button:
Voici le code d'origine:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 ??? Undefined function or method 'returnFunction' for input arguments of type 'double'. ??? Error while evaluating uicontrol Callback
Quelqu'un aurait il ou elle une idée pour rendre cette fonction "returnFunction" visible par l'uicontrol?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 classdef window0 < handle properties panel eventbutton end methods function obj=window0(varargin) switch nargin case 0, h=gcf; col=[0.8 0.8 0.89]; case 1, h=varargin{1}; col=[0.8 0.8 0.89] case 2, h=varargin{1}; col=varargin{2}; end obj.panel=uipanel(h,'units','normalized',... 'Position',[0.1 0.1 0.8 0.8],... 'BackGroundColor',col,... 'Title','test panel for object'); obj.eventbutton=uicontrol('Parent',obj.panel,... 'Style','Pushbutton',... 'String','click here',... 'Callback',@returnFunction); %returnFunction end function returnFunction(varargin) disp('called'); notify(obj,'click_on_pushB'); end end events click_on_pushB end end
Et sinon, comment ordonner le signalement d'un "event" par un uicontrol - pushbutton visible par d'autres objets?
Merci
Oodbae
Partager