-
November 9th, 2018, 23:18 #1
Dragging and linking a field without making a link graphic on it...
Hola.
I have a matrix of values on my character-sheet that can be manipulated through other fields. (IE, each is a combination of two others), this in turn can be dragged to a windowlist below. Is there a good way to LINK the value in the windowlist so that when I drop per example the contents of "Creo Ignem" on a spell slot it should now hold a link to the node and update when it is changed?
It feels like it should be obvious, I have seen it done on the combat tracker etc but can't seem to figure out the last step.
- Obe
-
November 9th, 2018, 23:54 #2
would stringcyclers be another way to handle this?
-
November 10th, 2018, 07:48 #3
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,561
I think you’d need a more specific example to get an idea of what you want to do.
For combat tracker, specific PC fields are synched between PC record and CT list item.
Regards,
JPG
-
November 11th, 2018, 00:13 #4
On the combined numberfield i have so far tried this...
function onDrag(button, x, y, draginfo)
local a, b, c
a = getValue();
b = description[1];
c = getName();
draginfo.setShortcutData("charsheet_magic","CrAn") ;
draginfo.setType("art");
draginfo.setDescription(b);
draginfo.setStringData(c);
draginfo.setNumberData(a);
return true;
end
The receiving numberfield inside a windowlist :
function onDrop(x, y, draginfo)
local temp1
local temp2
local temp3
if draginfo.getType() == "art" then
temp1 = draginfo.getNumberData();
temp2 = draginfo.getDescription();
temp3 = draginfo.getStringData();
local a,b = draginfo.getShortcutData();
print("Triggered Art " .. a .. " " ..b);
forms.setValue(temp3);
castingtotal.setValue(temp1);
end
if draginfo.getType() == "shortcut" then
temp1 = draginfo.getNumberData();
temp2 = draginfo.getDescription();
temp3 = draginfo.getStringData();
local a,b = draginfo.getShortcutData();
print("Triggered shortcut " .. a .. " " ..b);
forms.setValue(temp3);
castingtotal.setValue(temp1);
end
end
... the idea is of course to make a link similar to how it is done on the Combat-tracker. So I have a casting-total for each spell directly on it's listing.
-Obe
-
November 11th, 2018, 00:24 #5
-
November 11th, 2018, 01:43 #6
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,561
You’ll want to use onDragStart; instead of onDrag. The former is called once; the latter is called every time the mouse is moved.
For the capture; you won’t get any number/string data for the “shortcut” type; unless you have a custom drag function setting to shortcut plus extra data elsewhere.
Are you getting the correct values returned by print function? You can also use Debug.chat function to keep from having to check console.
Regards,
JPG
-
November 11th, 2018, 21:57 #7
Replaced the onDrag with onDragStart.
The line
draginfo.setShortcutData("charsheet_magic","CrAn") ;
passes over the class and the node name if understand correctly. But how do I turn this into a link so when I raise the CrAn score later the casting-score raises as well?
How do I recieve the data beyond
if draginfo.getType() == "art" then
temp1 = draginfo.getNumberData();
temp2 = draginfo.getDescription();
temp3 = draginfo.getStringData();
local a,b = draginfo.getShortcutData();
print("Triggered shortcut " .. a .. " " ..b);
forms.setValue(temp3);
castingtotal.setValue(temp1);
Which just gives it it's current value?
- Obe
-
November 11th, 2018, 22:47 #8
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,561
You would need to start retrieving database nodes based on the link passed; Store the node in a variable; set onUpdate and onDelete handlers for the node; and recalculate/remove based on the event.
The number_linked template and script does something like that. It takes the values passed in the template control XML tags; saves off the nodes; and updates the total when they change.
Regards,
JPG
-
November 12th, 2018, 23:09 #9
Spent most of the day fiddling with this. ... it didn't go particularily well.
function onDragStart(button, x, y, draginfo)
local a, b, c, d
a = getValue();
b = description[1];
c = getName();
local node = getDatabaseNode();
d = node.getPath();
draginfo.setShortcutData("charsheet_magic",d);
draginfo.setType("art");
draginfo.setDescription(b);
draginfo.setStringData(c);
draginfo.setNumberData(a);
draginfo.setCustomData(d);
return true;
end
gives me charsheet ID node name.
I can drop this to the recepient field (using a version of number_linked) which I fail to get to link to the node itself.
- Obe
-
November 12th, 2018, 23:26 #10
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,561
You are already setting the database node in setShortcutData(), so you don't need to add as custom data as well. Just pull out of draginfo.getShortcutData().
This probably isn't the part that's not working as expected, as the dragging is the easy part. It's the handling of the drop, and subsequent linked behavior that will be the meat of the logic.
Where's your code for the drop handling, as well as the handling for adding update events and updating when those events trigger?
Regards,
JPG
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks