wyldcard
wyldcard copied to clipboard
missing UI functionality: Option-click drag doesn't duplicate Parts
Look at how to HC works in duplicating objects with its attributes, not the content --at least not in HC
Hey @defano, hope all is well!
I did a study/prototype on how we might go about leveraging what's already there to make the above functionality work. I got most of it by overloading CardPartTransferHandler.importData(TransferHandler.TransferSupport info)
method to take an instance of a Transferable
object (transfer data being the ToolEditablePart
). This is because the create method in CardPartTransferHandler
is protected through a private class. I get it, the design is very deliberate about the clipboard and not suggesting my approach to change it, only to make a case for some refactoring work for duplication.
At any rate, I still don't have a good way of passing the initial dragging event from the copiedPart to the importedPart.
Please advise if you have any thoughts on both these issues. Would be highly appreciated.
Hmm, I don't have a good answer off the top of my head; would need to hack around a bit.
I would guess that you could invoke the mousePressed()
method directly on the new part, and pass it the MouseEvent
you received on the original part. There's probably some other state hacking you'd need to do, like set the newly duplicated part as having been selected... but I'd start there.
You might find that both parts start dragging then... you might have to make a copy of the original MouseEvent
before invoking mousePressed()
on the new part, then call .consume()
on the original event to get the original part from dragging along with the duplicated one.
Thanks Matt for quick reply, I will play around some more and propose a solution.
Sent from my iPhone
On May 31, 2022, at 8:02 PM, Matt DeFano @.***> wrote:
Hmm, I don't have a good answer off the top of my head; would need to hack around a bit.
I would guess that you could invoke the mousePressed() method directly on the new part, and pass it the MouseEvent you received on the original part. There's probably some other state hacking you'd need to do, like set the newly duplicated part as having been selected... but I'd start there.
You might find that both parts start dragging then... you might have to make a copy of the original MouseEvent before invoking mousePressed() on the new part, then call .consume() on the original event to get the original part from dragging along with the duplicated one.
— Reply to this email directly, view it on GitHubhttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdefano%2Fwyldcard%2Fissues%2F115%23issuecomment-1143066570&data=05%7C01%7C%7Cf080ec80d81b47dd7ad808da437b3a8c%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637896493783105821%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=TJRaDXkMdweL9Oly5pjcF8QlRO5l77UxG1rcFIMcIJg%3D&reserved=0, or unsubscribehttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAZ473WEMARYKZ64WE2DMBLVM3HGBANCNFSM5XGGFF4Q&data=05%7C01%7C%7Cf080ec80d81b47dd7ad808da437b3a8c%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637896493783105821%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=hW9DV6eJdu%2Fv2J4J0KsIOmrFpIcJG6tuXs3JuJRaiFA%3D&reserved=0. You are receiving this because you authored the thread.Message ID: @.***>