{***********************************************************************}
{									}
{ __DelDKMnu  Delete a _Key record from the linked list of default keys }
{									}
{ function  __DKeyMnu(Key : _Keys) boolean;				}
{									}
{	      Key	Keystroke definition of type Unit_Key._Keys	}
{									}
{ Description This function deletes a keystroke definition from the	}
{	      list of default keystroke definitions pointed to by	}
{	      DefaultKeyPtr_.  The purpose of the default list is to	}
{	      avoid redefinition of keystrokes which are usually common }
{	      to all menus, e.g. arrow keys, TAB, ENTER, etc.  When	}
{	      __MakeMnu creates a new _Menu record, it copies this	}
{	      list, then sets _MKeysPtr to point at the first element	}
{	      in the list.  The initial contents of the default list	}
{	      is defined in the typed constant array InitKeys, found	}
{	      in Unit_Mnu.pas.						}
{									}
{	      This function allows you to delete items from the list,	}
{	      so that your customized defaults will be attached to any	}
{	      subsequent menu you create.  See __DefKyMnu to add de-	}
{	      fault keystroke definitions, __KeyMnu and __DelKyMnu to	}
{	      add or delete keys to a specific menu.			}
{									}
{	      The function returns TRUE if the key was successfully	}
{	      deleted, FALSE on failure.				}
{									}
{	      On error _MenuError may be set to:  _InvalidKey		}
{									}
{ Version     4.00 (C)Copyright Blaise Computing Inc. 1987		}
{_______________________________________________________________________}

function __DelDKMnu(Key : _Keys) : boolean;

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

  begin

    __DelDKMnu := FALSE;
    ChSc       := Unit_Key._KeyTable[Key];

    { Traverse the list of _Key records, if any, looking for a match.	}

    TempPtr := DefaultKeyPtr_;
    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 item and release all	}
	     { memory used by the key record.				}

	     if (TempPtr = DefaultKeyPtr_) then
		DefaultKeyPtr_ := TempPtr^._NextKey
	     else
		LastPtr^._NextKey  := TempPtr^._NextKey;
	     FreeMem(TempPtr,sizeof(_Key));
	     __DelDKMnu := TRUE;
	     Exit
	   end
	else
	   begin
	     LastPtr := TempPtr;
	     TempPtr := TempPtr^._NextKey
	   end
      end;

    SetMenuError(_InvalidKey)	       { No key record found		}

  end; {__DelDKMnu}
