function onax=pdeonax(ax)
%PDEONAX Checks if current pointer position is inside PDE Toolbox axes area
%	Returns 1 if inside axes area, 0 otherwise.
%
%	PDEONAX(AX) checks if inside the axes with handle AX.
%	PDEONAX checks if inside PDE Toolbox axes.

%	Magnus Ringh 9-21-94, MR 11-23-94.
%	Copyright (c) 1994-95 by The MathWorks, Inc.
%	$Revision: 1.3.1.1 $  $Date: 1995/08/14 15:06:14 $

if nargin==0,
  pde_fig=findobj(get(0,'Children'),'flat','Tag','PDETool');
  ax=findobj(get(pde_fig,'Children'),'flat','Tag','PDEAxes');
end
if ~isempty(ax)
  lim=get(ax,'RenderLimits');
  xlim=lim(1:2); ylim=lim(3:4);
  pv=get(ax,'CurrentPoint');
  onax = (pv(1,1) >=  xlim(1) & pv(1,1) <= xlim(2) &...
      pv(1,2) >= ylim(1) & pv(1,2) <= ylim(2));
else
  error('PDE Toolbox not active');
end
