function theResult = PXEvent(self, thePXEvent, theMessage)

% PXEvent -- Event handler for PXPatch.
%  PXEvent(self, thePXEvent, theMessage) processes thePXEvent
%   and theMessage on behalf of self, a "pxpatch" object.
 
% Copyright (C) 1997 Dr. Charles R. Denham, ZYDECO.
%  All Rights Reserved.
%   Disclosure without explicit written consent from the
%    copyright owner does not constitute publication.
 
% Version of 23-Apr-1997 08:55:57.

if nargin < 1, help(mfilename), return, end
if nargin < 2, thePXEvent = ''; end
if nargin < 3, theMessage = []; end

result = [];

h = px(self);

switch lower(thePXEvent)
case {'buttondownfcn', ''}
   set(h, 'SelectionHighlight', 'on')
   switch lower(get(h, 'Selected'))
   case 'off'
      switch lower(get(gcf, 'SelectionType'))
      case 'normal'
         set(h, 'Selected', 'on')
      case 'extend'
         set(h, 'Selected', 'off')
      otherwise
      end
   case 'on'
      switch lower(get(gcf, 'SelectionType'))
      case 'normal'
         set(h, 'Selected', 'off')
      case 'extend'
         set(h, 'Selected', 'on')
      otherwise
      end
   otherwise
   end
   theCallback = pxget(self, 'itsCallback');
   if ~isempty(theCallback) & isstr(theCallback)
      feval(theCallback, {self})
   end
otherwise
   result = PXEvent(super(self), thePXEvent, theMessage)
end

if nargout > 0, theResult = result; end
