ApesAmongUs
September 16th, 2020, 17:37
OK, I have a feeling I'm lacking some fundamental understanding of how drag and drop works. First the background...
1. template_cardhand.xml holds 2 templates <template name="cardhand"> and <template name="card">.
2. I want to replace the scripts/functions for "card", so I added this to my extension.xml file
<root>
<base>
<template name="card">
<genericcontrol>
<anchored width="45" height="45">
<left />
<top offset="15" />
</anchored>
<script file="common/scripts/template_card.lua" />
</genericcontrol>
</template>
</base>
</root>
And added the replacement "template_card.lua" file into my extension zip. This works fine. The changes I make to the functions in the lua file apply to cards inside FG.
But previously, you could drag cards from one hand to another, but now that is broken. It never managed to pick up the card to drag. Clicking and dragging now moved the whole window just as it does it you click elsewhere on the window where there isn't a card.
3. The obvious assumption is that I broke something with my code, so I replaced my edited template_card.lua file with the original. So, now the extension is replacing the script file with an exact copy of itself. It's not the changes to the script/lua file that I made that are causing the problem.
But this doesn't work.
4. Next obvious problem would be that I screwed up something in building the extension, and that's screwing it up. To test that, I commented out the open and close template tags (above) and everything between them.
That fixes it. So, breaking of the drag and drop happens somewhere between those 2 tags. But everything in there is an exact copy of what is in the original template_cardhand.xml file.
Is there something about where the template is defined that somehow breaks the code for drag and drop? That code is located within that lua file, so it should be there in that same context.
Anyone have a clue as to the important conceptual part about drag/drop that I am missing? If you can tell me how to fix it, that is great, but even better would be helping me understand why it matters.
1. template_cardhand.xml holds 2 templates <template name="cardhand"> and <template name="card">.
2. I want to replace the scripts/functions for "card", so I added this to my extension.xml file
<root>
<base>
<template name="card">
<genericcontrol>
<anchored width="45" height="45">
<left />
<top offset="15" />
</anchored>
<script file="common/scripts/template_card.lua" />
</genericcontrol>
</template>
</base>
</root>
And added the replacement "template_card.lua" file into my extension zip. This works fine. The changes I make to the functions in the lua file apply to cards inside FG.
But previously, you could drag cards from one hand to another, but now that is broken. It never managed to pick up the card to drag. Clicking and dragging now moved the whole window just as it does it you click elsewhere on the window where there isn't a card.
3. The obvious assumption is that I broke something with my code, so I replaced my edited template_card.lua file with the original. So, now the extension is replacing the script file with an exact copy of itself. It's not the changes to the script/lua file that I made that are causing the problem.
But this doesn't work.
4. Next obvious problem would be that I screwed up something in building the extension, and that's screwing it up. To test that, I commented out the open and close template tags (above) and everything between them.
That fixes it. So, breaking of the drag and drop happens somewhere between those 2 tags. But everything in there is an exact copy of what is in the original template_cardhand.xml file.
Is there something about where the template is defined that somehow breaks the code for drag and drop? That code is located within that lua file, so it should be there in that same context.
Anyone have a clue as to the important conceptual part about drag/drop that I am missing? If you can tell me how to fix it, that is great, but even better would be helping me understand why it matters.