source: trunk/src/mouse_alt_gui.m @ 295

Last change on this file since 295 was 287, checked in by sommeria, 9 years ago

further cleaning after new GUI civ. The function mouse_alt_gui allows to zoom out a uicontrol and edit it

File size: 3.1 KB
Line 
1%'mouse_alt_gui': function activated when the right mouse button is pressed on a GUI (callback for 'WindowButtonDownFcn')
2% it displays an editable msg box with zoom of the current uicontrol display
3%------------------------------------------------------------------------
4function mouse_alt_gui(hObject,eventdata,handles)
5%------------------------------------------------------------------------
6if isequal(get(hObject,'SelectionType'),'alt')
7    set(hObject,'Units','pixels')
8    GUI_pos=get(hObject,'Position');%position on the screen  (in pixels)  of the GUI selected by the mouse
9    set(hObject,'Units','normalized')
10    xy_fig=get(hObject,'CurrentPoint');% current point of the current GUI
11    hchildren=get(hObject,'Children');%handles of all objects in the current GUI
12    %% loop on all the objects in the current figure (selected by the last mouse click)
13    for ichild=1:length(hchildren)
14        hchild=hchildren(ichild);
15        obj_pos=get(hchild,'Position');%position of the object
16        if numel(obj_pos)>=4 && xy_fig(1) >=obj_pos(1) && xy_fig(2) >= obj_pos(2)&& xy_fig(1) <=obj_pos(1)+obj_pos(3) && xy_fig(2) <= obj_pos(2)+obj_pos(4);
17            htype=get(hchild,'Type');%type of object child of the current figure
18            switch htype
19                case 'uicontrol'
20                    %if the mouse is over a uicontrol, look at the data
21                    if strcmp(get(hchild,'Visible'),'on')
22                        msg_pos(1:2)=GUI_pos(1:2)+obj_pos(1:2).*GUI_pos(3:4);
23                        output_str=msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],'',get(hchild,'String'),msg_pos);
24                        break
25                    end
26                case 'uipanel'
27                    panel_pos=obj_pos;%position of the panel
28                    hhchildren=get(hchild,'Children');%handles of all objects in the current GUI
29                    %% loop on all the objects in the current figure (selected by the last mouse click)
30                    for iichild=1:length(hhchildren)
31                        hchild=hhchildren(iichild);
32                        rel_pos=get(hchild,'Position');%position of the object relative to the uipanel
33                        obj_pos(1:2)=panel_pos(1:2)+rel_pos(1:2).*panel_pos(3:4);
34                        obj_pos(3:4)=panel_pos(3:4).*rel_pos(3:4);
35                        if numel(obj_pos)>=4 && xy_fig(1) >=obj_pos(1) && xy_fig(2) >= obj_pos(2)&& xy_fig(1) <=obj_pos(1)+obj_pos(3) && xy_fig(2) <= obj_pos(2)+obj_pos(4);
36                            htype=get(hchild,'Type');%type of object child of the current figure
37                            %if the mouse is over a uicontrol, look at the data
38                            if strcmp(htype,'uicontrol') && strcmp(get(hchild,'Visible'),'on')
39                                msg_pos(1:2)=GUI_pos(1:2)+obj_pos(1:2).*GUI_pos(3:4);
40                                output_str=msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],'',get(hchild,'String'),msg_pos);
41                                break
42                            end
43                        end
44                    end
45            end
46           
47        end
48    end
49    set(hObject,'Units','pixels')
50    set(hchild,'String',output_str)
51end
Note: See TracBrowser for help on using the repository browser.