source: trunk/src/activate.m @ 620

Last change on this file since 620 was 620, checked in by sommeria, 11 years ago

bugs repaired in series + cleaning.
Introducing of a demo program (test stage)

File size: 1.7 KB
RevLine 
[620]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
11function activate(FigTag,PanelTag,ObjectTag,Value)
12hFig=findobj(allchild(0),'tag',FigTag);
13set(0,'CurrentFigure',hFig)
14handles=guidata(hFig);
15unit_0=get(0,'Unit');
16unit=get(hFig,'Unit');
17set(hFig,'Unit',unit_0)
18FramePos=get(hFig,'Position');
19set(hFig,'Unit',unit)
20if isempty(PanelTag)
21    hPanel=hFig;
22    hObject=handles.(ObjectTag);
23else
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)
29end
30hObject=handles.(ObjectTag);
31if isempty(hObject)
32    disp(['Object' ObjectTag ' not found'])
33else
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)
55end
Note: See TracBrowser for help on using the repository browser.