1 | % 'activate': emulate the mouse selection of a GUI element, for demo |
---|
2 | %----------------------------------------------------------------------- |
---|
3 | % function activate(FigTag,PanelTag,ObjectTag,Value) |
---|
4 | % |
---|
5 | % INPUT: |
---|
6 | % FigTag: tag name of the GUI figure (e.g; 'uvmat') |
---|
7 | % PanelTag: tag name of a uipanel containing the element, =[] if no panel |
---|
8 | % ObjectTag: tag name of the element |
---|
9 | % Value: value set to the element, for instance string to select on a menu |
---|
10 | |
---|
11 | function activate(FigTag,PanelTag,ObjectTag,Value) |
---|
12 | hFig=findobj(allchild(0),'tag',FigTag); |
---|
13 | set(0,'CurrentFigure',hFig) |
---|
14 | handles=guidata(hFig); |
---|
15 | unit_0=get(0,'Unit'); |
---|
16 | unit=get(hFig,'Unit'); |
---|
17 | set(hFig,'Unit',unit_0) |
---|
18 | FramePos=get(hFig,'Position'); |
---|
19 | set(hFig,'Unit',unit) |
---|
20 | if isempty(PanelTag) |
---|
21 | hPanel=hFig; |
---|
22 | hObject=handles.(ObjectTag); |
---|
23 | else |
---|
24 | hPanel=findobj(hFig,'tag',PanelTag); |
---|
25 | unit=get(hPanel,'Unit'); |
---|
26 | set(hPanel,'Unit',unit_0) |
---|
27 | FramePos=FramePos+get(hPanel,'Position'); |
---|
28 | set(hPanel,'Unit',unit) |
---|
29 | end |
---|
30 | hObject=handles.(ObjectTag); |
---|
31 | if isempty(hObject) |
---|
32 | disp(['Object' ObjectTag ' not found']) |
---|
33 | else |
---|
34 | if exist('Value','var') |
---|
35 | if isempty(PanelTag) |
---|
36 | Param.(ObjectTag)=Value; |
---|
37 | else |
---|
38 | Param.(PanelTag).(ObjectTag)=Value; |
---|
39 | end |
---|
40 | errormsg=fill_GUI(Param,hFig); |
---|
41 | end |
---|
42 | unit=get(hObject,'Unit'); |
---|
43 | set(hObject,'Unit',unit_0); |
---|
44 | Pos=get(hObject,'Position'); |
---|
45 | set(hObject,'Unit',unit) |
---|
46 | set(0,'PointerLocation',FramePos(1:2)+Pos(1:2)) |
---|
47 | BackgroundColor=get(hObject,'BackgroundColor'); |
---|
48 | set(hObject,'BackgroundColor',[1 1 0]) |
---|
49 | for ipos=1:10 |
---|
50 | set(0,'PointerLocation',FramePos(1:2)+Pos(1:2)+0.5*(ipos/10)*Pos(3:4)) |
---|
51 | pause(0.2) |
---|
52 | end |
---|
53 | feval(FigTag,[ObjectTag '_Callback'],hObject,[],handles); |
---|
54 | set(hObject,'BackgroundColor',BackgroundColor) |
---|
55 | end |
---|