I made a pseudo-copy of the function a few years ago for this mod: https://www.nexusmod...out4/mods/28945
It was a pain. Here's the Papyrus bit:
Annoyingly, there are a number of quest items registered with components, and there isn't any way to differentiate quest items (i.e. things that couldn't normally be removed from your inventory) from any other scrap, so the best I could come up with was to manually maintain a FormList of those and just transfer them back to the player if they get taken.
I never managed to get the "real" button to work. I believe the way it works is that activating a container directly from the "special" TRANSFER UI button—provided by containers with WorkshopKeyword (defined by the Workshop Default Object in the CK), or a workbech/crafting station linked to one such container via WorkshopItemKeyword (defined by the WorkshopItem DFOB etc)—sets some state that watches for the extra button press event or whatever, and somehow links the UI button up to that; and also passes some extra data into the ContainerMenu Scaleform object that sets uiMode to 6 (CM_WORKBENCH), which enables the "native" button in the UI: https://i.imgur.com/7jlly14.png
And you can change this so it will show up in other containers, but that only
changes the UI. it doesn't actually make the button work. https://i.imgur.com/f6tR5qS.jpg
I think the only way you could get this to work is by being really good at reverse engineering, and then use that to create an F4SE plugin that allows you to open containers in "workbench" mode. I don't think it's possible to "trick" it to work with other containers without completely breaking the workshop system (changing the Default Object).