Cocoa: Improve Undo/Redo handling for when COCOALOOPHIJACK is defined. See merge request freepascal.org/lazarus/lazarus!361