function junk = tpostset(h)
%TPOSTSET  PostSet function for target change

%   Author(s): A. DiVergilio
%   Copyright 1986-2000 The MathWorks, Inc. 
%   $Revision: 1.5 $  $Date: 2000/08/02 16:05:47 $

junk = []; %---Temporary fix

if isempty(h.Target)
   %---If clearing Target, hide GUI
   h.GUI.setVisible(0);
   
else
   %---Install listeners for new Target   
   hgP = findpackage('hg');
   uicC = findclass(hgP,'uicontextmenu');
   PointOfAttachment = h.Target;
      %---Listen for changes in Target's UserData (RespObj)
       EventSrc = uicC.findprop('UserData');
       EventType = 'PropertyPostSet';
       Callback = {@localUpdate,h};
       h.TargetUserDataListener = handle.listener(PointOfAttachment,EventSrc,EventType,Callback);
      %---Listen for Target destruction
       EventType = 'ObjectBeingDestroyed';
       Callback = {@localClose,h};
       h.TargetDestroyedListener = handle.listener(PointOfAttachment,EventType,Callback);
      %---Listen for BackgroundAxes destruction
       ax = get(h.Target.UserData,'BackgroundAxes');
       EventType = 'ObjectBeingDestroyed';
       Callback = {@localClose,h};
       h.BackgroundAxesDestroyedListener = handle.listener(ax,EventType,Callback);

   %---Show which plot is selected
    set(ax,'XLim',[0 1],'YLim',[0 1],'XLimMode','manual','YLimMode','manual');
    h.Line = line('Parent',ax,'Clipping','off','XData',[],'YData',[],'LineStyle','--');
   %---Refresh line (will resize line to encompass backgroundaxes and labels)
    h.refresh;

   %---Read response properties
    h.readprops;

   %---Pack frame
    h.GUI.pack;
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Pass these callbacks to class methods %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function localUpdate(eventSrc,eventData,h)
 h.readprops;
 h.refresh;

function localClose(eventSrc,eventData,h)
 h.close;
