{***********************************************************************}
{									}
{ __DelKyMnu  Delete a _Key record from a menu				}
{									}
{ function  __DelKyMnu(MenuPtr : _MenuPtr; Key : _Keys) : boolean;	}
{									}
{	      MenuPtr	Pointer to the menu from which the keystroke	}
{			will be deleted.				}
{	      Key	The keystroke to be deleted.			}
{									}
{ Description __DelKyMnu deletes a single _Key record in the  key	}
{	      list for the menu pointed to by MenuPtr.			}
{									}
{	      __DelKyMnu searches the list for a keystroke with a	}
{	      character and scan code which matches those of Key.	}
{	      If a match is found the existing record is deleted,	}
{	      and the function returns TRUE, otherwise the		}
{	      function returns FALSE.					}
{									}
{	      See __DelDKMnu to delete keystrokes from the default	}
{	      list.							}
{									}
{ Version     4.00 (C)Copyright Blaise Computing Inc. 1987		}
{_______________________________________________________________________}

function __DelKyMnu(MenuPtr : _MenuPtr; Key : _Keys) : boolean;

  var
    TempPtr,LastPtr   : _KeyPtr;
    TempIPtr	      : _ItemPtr;
    Found	      : boolean;
    ChSc	      : _KeySeq;

  begin

    __DelKyMnu	:= FALSE;

    if (not ValidSig(MenuPtr,MENUSIG_)) then
       Exit;			       { Menu pointer is invalide	}

    { Next we traverse the list of _Keys, if any, looking for a match.	}
    { A match is a record with an identical keystroke (_KChSc). 	}

    ChSc      := _KeyTable[Key];
    TempPtr   := MenuPtr^._MKeysPtr;
    LastPtr   := TempPtr;

    while (TempPtr <> NIL) do
      begin
	if (not ValidSig(TempPtr,KEYSIG_)) then
	   Exit;
	if (TempPtr^._KChSc._ChScan = ChSc._ChScan) then
	   begin

	     { Reset pointers to exclude deleted key and free the	}
	     { memory used by the key record.				}

	     if (TempPtr = MenuPtr^._MKeysPtr) then
		MenuPtr^._MKeysPtr := TempPtr^._NextKey
	     else
		LastPtr^._NextKey  := TempPtr^._NextKey;
	     TempPtr^._KSig	  := ' ';
	     FreeMem(TempPtr,sizeof(_Key));
	     __DelKyMnu := TRUE;
	     Exit
	   end;
	LastPtr := TempPtr;
	TempPtr := TempPtr^._NextKey
      end;

    SetMenuError(_InvalidKey)	       { No matching key found. 	}

  end;	{__DelKyMnu}
