Starfinder Playlist
Page 1 of 2 12 Last
  1. #1

    Overriding template breaks drag and drop

    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

    <template name="card">
    <anchored width="45" height="45">
    <left />
    <top offset="15" />
    <script file="common/scripts/template_card.lua" />

    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.

  2. #2
    Drag and drop is completely implemented by the individual controls and windows, using onDragStart, onDrag, onDragEnd, and onDrop events.

    It might help if you posted your simple extension from Step 3 to help look at.


  3. #3
    Here you go.

    Edit: forgot to mention, SavageWorlds base ruleset.
    Attached Files Attached Files
    Last edited by ApesAmongUs; September 16th, 2020 at 18:08.

  4. #4
    Still trying to figure this out. Does anyone have any ideas?

  5. #5
    Are you developing in FGU or FGC? Are you loading other extensions with yours?


  6. #6
    FGC. The problem occurs with just that extension enabled.

  7. #7
    Apologies that I haven't had much time to help with this. I've been heads down trying to coordinate new FGU internal builds and testing. Also, I'm not the Savage Worlds developer, and I'm just poking around; so I can only guess at the issue or provide some ideas.

    I was just looking a little deeper inside the extension; and notice that you are overriding the "card" template. But, the "card" template is only used in the "deck" window class.

    Given the name of your extension, it seems like you would be trying to modify the combat tracker. In the "combatant" window class, it uses a "actioncard_selection" template to show the card for the user.

    Are you sure that you're overriding the right template for the UI element you are trying to override?

    What part of the UI are you trying to modify? Does it

  8. #8
    Yes and No. For the "yes" part, changes I have made to that template do have an effect when I interact with the cards in the combat tracker. I (more or less) have it working with changing only template_card. It's just when I make it work, it stops the dragging and dropping from working.

    But for the "No" part, I don't know why that happens - there may be another place to make changes. It appears there is some inheritance going on somewhere. I may need to modify other templates eventually after I figure out what is the problem with replacing this one.

    What I'm changing (ultimately) is the effects of clicking on the card in card hand that is part of the combat tracker for each character in the tracker. Those use the "template_card" and the "template_cardhand". I think "actioncard_selection" may be the card that displays on the left hand side of the combat tracker.

  9. #9
    Got a chance to dig in a little more. The reason that "onDragStart" is not firing is because it was added in v2.8; and the compatibility version on your extension is set to v2.6. Try changing the version tag in the extension.xml file to [version="3.0"]


  10. #10
    Thank you so much. I didn't even know that was a thing. I had just copied that header from an ext that I knew worked and was modifying from there. It makes sense, but I would never have found that on my own.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Fantasy Grounds Fridays Pre

Log in

Log in