Thread: Looking for advice-script
-
August 21st, 2009, 00:13 #1
- Join Date
- Apr 2009
- Location
- Fullerton, CA.
- Posts
- 625
Looking for advice-script
Hello,
I have added to my charsheet a window control that allows me to drag an "armor" link from a library reference, drop it, and have the shortcut cut information populate some pre-exisitng windows.
So far this works fine.
When you left mouse single click the shortcut it opens the shortcut information window, and on a left mouse double click clears the information that was set.
Middle mouse button clears the link from the control.
Again, this portion works, but not exactly how I wanted. I would like the control to be cleared of the link by single click middle mouse, and the information cleared either at the same time, or on a double click, leaving the left mouse button free to do default actions.
I have the script I am using below. How can I change it to do double middle click? My coding skills are "hacktastic" at best, basically I can get away with changing code to get the tweaks I want, this time I am a bit over my head.
Surprised I have it working quite frankly- I am just trying to make sure I am not doing something I can or should avoid doing while scripting too.
(thanks Foen, by searching the boards, some of your old posts lead me down the "click" path...lol you guys are great btw)
function onDrop(x, y, draginfo)
if draginfo.isType("shortcut") then
local link = draginfo.getShortcutData();
if link == "referencearmor" then
local sourcenode = draginfo.getDatabaseNode();
local type = sourcenode.getChild("type").getValue();
if type == "Light armor" or type == "Medium armor" or type == "Heavy armor" then
window.armorshortcut.setValue(draginfo.getShortcut Data());
window.armorname.setValue(sourcenode.getChild("nam e").getValue());
window.armormaxdexbonus.setValue(sourcenode.getChi ld("maxdex").getValue());
window.armorcheckpenalty.setValue(sourcenode.getCh ild("checkpenalty").getValue());
window.drarmor.setValue(sourcenode.getChild("dr"). getValue());
window.maxspeed.setValue(sourcenode.getChild("spee d30").getValue());
end
return true;
end
end
end
function onClickDown(button, x, y)
return true;
end
function onDoubleClick(button, x)
window.armorname.setValue(armorname, "");
window.armormaxdexbonus.setValue(armormaxdexbonus, 0);
window.armorcheckpenalty.setValue(armorcheckpenalt y,0);
window.drarmor.setValue(drarmor, 0);
window.maxspeed.setValue(maxspeed, 0);
return true;
end
-
August 21st, 2009, 06:31 #2
I'd suggest you move the code from onDoubleClick to onClickRelease and check that the button parameter is set to 2 (middle button):
Code:function onClickRelease(button, x, y) if button==2 then window.armorname.setValue(armorname, ""); window.armormaxdexbonus.setValue(armormaxdexbonus, 0); window.armorcheckpenalty.setValue(armorcheckpenalt y,0); window.drarmor.setValue(drarmor, 0); window.maxspeed.setValue(maxspeed, 0); end end
You might find the reference material useful (https://www.fantasygrounds.com/refdoc/) as it includes documentation for all these events. The onClickRelease event is listed under the windowcontrol entry.
Hope that helps,
Foen
-
August 21st, 2009, 10:47 #3
- Join Date
- Apr 2009
- Location
- Fullerton, CA.
- Posts
- 625
I returned to true so I could capture the double click and use it to set the new data.
I couldn't figure out how to grab the middle button. I see where I went wrong.
I do want to use onClickRelease with the middle mouse button, and have a one click feature to clear everything.
This looks like exactly what I am after.
Thanks.
PS: I do use the docs, hard for me to follow without examples of usage most of the time. So, when I am stuck beyond what I can do, it sure is nice to have a helpful community!Last edited by Paul Pratt; August 21st, 2009 at 10:52.
-
August 21st, 2009, 11:00 #4
Returning 'true' to enable onClickRelease and onDoubleClick *is* needed in onClickDown, but *isn't* needed in onClickRelease. I think.
Happy to help out: it wasn't so long ago that I was new here, and I found folks like Joshuha and moon_wizard really helpful to me.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks