STAR TREK 2d20
  1. #1

    dragData in onDragStart() returning true/false/nil

    Discussion came up on the discord channel and it was mentioned that one could "edit" the drag data instead of having to fill in the rest (and keep what would normally be there). I tested myself and was unable to get this to work and Moon requested I post it here for later discussions.


    Code:
        <template name="link_audiostop">
        <linkcontrol name="audioshortcut">
          <script>
            function onDragStart(button, x, y, draginfo)
              local node = window.getDatabaseNode();
              draginfo.setDescription(DB.getValue(node,"name","") .. " [stop]");
              return nil;
            end
          </script>
          <class>urlaudiostop</class>
          <icon normal="link_audio" pressed="link_audio_down" empty="button_link_empty" />
        </linkcontrol>
      </template>
    I couldn't get the "nil" return value to change the description using the above method. This is what I have that is working for now. This fills in ALL the data since the datainfo value is empty on start.


    Code:
    	<template name="link_audiostop">
        <linkcontrol name="audioshortcut">
          <script>
            function onDragStart(button, x, y, draginfo)
              local node = window.getDatabaseNode();
              draginfo.setDescription(DB.getValue(node,"name","") .. " [stop]");
              draginfo.setShortcutData("urlaudiostop",node.getPath())
              draginfo.setIcon("link_audio");
              draginfo.setType("shortcut");
              return true;
            end
          </script>
          <class>urlaudiostop</class>
          <icon normal="link_audio" pressed="link_audio_down" empty="button_link_empty" />
        </linkcontrol>
      </template>
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  2. #2
    Just looked at the code. The drag object for default behavior is not created until after scripts are completed. The one passed to onDragStart/onDrag scripts is a "temp" drag object that is only used if you return true/false. So, you'll have to use the full override.

    Regards,
    JPG

Thread Information

Users Browsing this Thread

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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Character Create Playlist

Log in

Log in