Changeset 627 for trunk/src/activate.m


Ignore:
Timestamp:
May 3, 2013, 10:11:43 AM (8 years ago)
Author:
sommeria
Message:

a few bugs repaired, display of the local mouse indication in a separate window

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/activate.m

    r620 r627  
    77% PanelTag: tag name of a uipanel containing the element, =[] if no panel
    88% ObjectTag: tag name of the element
     9% Position=[x y] coordinates set for the mouse relative to the object (default =[] corresponds to the centre [0.5 0.5]
    910% Value: value set to the element, for instance string to select on a menu
    1011
    11 function activate(FigTag,PanelTag,ObjectTag,Value)
     12function activate(FigTag,PanelTag,ObjectTag,Position,Value)
    1213hFig=findobj(allchild(0),'tag',FigTag);
    1314set(0,'CurrentFigure',hFig)
     15% xx=double(get(hFig,'CurrentCharacter')); %get the keyboard character
     16% if isequal(xx,27) % key escape
     17%     pause
     18% end
    1419handles=guidata(hFig);
    1520unit_0=get(0,'Unit');
    1621unit=get(hFig,'Unit');
    1722set(hFig,'Unit',unit_0)
    18 FramePos=get(hFig,'Position');
     23FramePos=get(hFig,'Position');% position of the figure
    1924set(hFig,'Unit',unit)
    2025if isempty(PanelTag)
     
    2732    FramePos=FramePos+get(hPanel,'Position');
    2833    set(hPanel,'Unit',unit)
     34end
     35if ~exist('Position','var')
     36    Position=[];
     37end
     38if isempty(Position)
     39    Position=[0.5 0.5];
     40end
     41if ~exist('Value','var')
     42    Value=[];
    2943end
    3044hObject=handles.(ObjectTag);
     
    3953        end
    4054        errormsg=fill_GUI(Param,hFig);
     55        if ~isempty(errormsg)
     56            disp(errormsg)
     57        end
     58%         if isequal(get(handles.(ObjectTag),'Style'),'pushbutton')
     59%             set(handles.(ObjectTag),'Value',Value)
     60%         end
    4161    end
    4262    unit=get(hObject,'Unit');
     
    4464    Pos=get(hObject,'Position');
    4565    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])
     66    CurrentPointerLoc=get(0,'PointerLocation');
     67    NewPointerLoc=FramePos(1:2)+Pos(1:2)+Position.*Pos(3:4);
     68    set(0,'PointerLocation',FramePos(1:2)+Pos(1:2)+Position.*Pos(3:4)) 
    4969    for ipos=1:10
    50         set(0,'PointerLocation',FramePos(1:2)+Pos(1:2)+0.5*(ipos/10)*Pos(3:4))
     70        set(0,'PointerLocation',CurrentPointerLoc+0.1*ipos*(NewPointerLoc-CurrentPointerLoc))
    5171        pause(0.2)
    5272    end
     73    if strcmp(get(hObject,'Style'),'axes')
     74        mouse_down(hFig,[])
     75        mouse_up(hFig,[])
     76    else
     77    BackgroundColor=get(hObject,'BackgroundColor');
     78    set(hObject,'BackgroundColor',[1 1 0])% mark activation of the object
     79    drawnow
    5380    feval(FigTag,[ObjectTag '_Callback'],hObject,[],handles);
     81        pause(2)
    5482    set(hObject,'BackgroundColor',BackgroundColor)
     83    end
    5584end
     85%%%%text display
     86if isempty(Value)
     87disp(['mouse select ' ObjectTag ' in ' FigTag ' ' PanelTag])
     88else
     89    disp(['set ' Value ' in ' FigTag ' ' PanelTag ' ' ObjectTag])
     90end
Note: See TracChangeset for help on using the changeset viewer.