annotate aim-mat/tools/@parameter/setcallback.m @ 4:537f939baef0 tip

various bug fixes and changed copyright message
author Stefan Bleeck <bleeck@gmail.com>
date Tue, 16 Aug 2011 14:37:17 +0100
parents 20ada0af3d7d
children
rev   line source
tomwalters@0 1 % method of class @parameter
tomwalters@0 2 %
bleeck@3 3 % (c) 2011, University of Southampton
bleeck@3 4 % Maintained by Stefan Bleeck (bleeck@gmail.com)
bleeck@3 5 % download of current version is on the soundsoftware site:
bleeck@3 6 % http://code.soundsoftware.ac.uk/projects/aimmat
bleeck@3 7 % documentation and everything is on http://www.acousticscale.org
tomwalters@0 8 function param=setcallback(param,text,cback,inbox)
tomwalters@0 9 % every entry can have a callback function that is called when the item
tomwalters@0 10 % looses its focus
tomwalters@0 11
tomwalters@0 12 cont=param.entries;
tomwalters@0 13 nrent=length(cont);
tomwalters@0 14
tomwalters@0 15 if nargin<4
tomwalters@0 16 inbox='all';
tomwalters@0 17 end
tomwalters@0 18 nr=-1;
tomwalters@0 19 % text can be a string or a number
tomwalters@0 20 if isstr(text) % if its a sting then look for the member number
tomwalters@0 21 % first search for the exact fit
tomwalters@0 22 for i=1:nrent
tomwalters@0 23 if strcmp(cont{i}.text,text) && (strcmp(cont{i}.panel,inbox) || strcmp(inbox,'all'))
tomwalters@0 24 nr=i;
tomwalters@0 25 break
tomwalters@0 26 end
tomwalters@0 27 end
tomwalters@0 28 % then search for the abbreviation
tomwalters@0 29 for i=1:nrent
tomwalters@0 30 if ~isempty(strfind(cont{i}.text,text)) && (strcmp(cont{i}.panel,inbox) || strcmp(inbox,'all'))
tomwalters@0 31 nr=i;
tomwalters@0 32 break
tomwalters@0 33 end
tomwalters@0 34 end
tomwalters@0 35 else
tomwalters@0 36 nr=text; % in this case we wanted to access it by the number
tomwalters@0 37 end
tomwalters@0 38
tomwalters@0 39
tomwalters@0 40 if nr>0
tomwalters@0 41 param.entries{nr}.callback=cback;
tomwalters@0 42 return
tomwalters@0 43 else
tomwalters@0 44 val='setcallback:: error, the entry does not exist';
tomwalters@0 45 end