PDA

View Full Version : Help With Coding Single Link (Not In A List)



dulux-oz
March 6th, 2014, 07:50
Hi Guys,

I'm trying to right the XML/LUA code to have a Link to a Map - I've looked at the various lists which allow you to drag and drop an entity's shortcut into the list, but what I want is a one-of entry, not a list, so I'm having trouble.

What I'd lick is (for eg)



<label_column>
<anchor>MapLink</anchor>
<static text="Map" />
</label_column>
<Some other template which would hold the name of the map (filename) plus a Shortcut Icon. name="MapLink" />


Any ideas/help would be appreciated.

Cheers

Trenloe
March 6th, 2014, 11:57
Are you trying to do something like the linkfield at the right of a skill entry on the character sheet in the 3.5e ruleset?

If so, have a look at the campaign\record_char_skills.xml file - the "char_skill" windowclass defines each skill entry and the "shortcut" linkfield is where a link can be dropped:

<linkfield name="shortcut">
<anchored width="20" height="20">
<top offset="2" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-2" />
</anchored>
<allowdrop />
</linkfield>

<linkfield> is a template that can be found in common\template_common.xml in the CoreRPG ruleset.

dulux-oz
March 6th, 2014, 12:14
That sounds like what I'm after - I'll have a look see and get back to you if I have ay further issues/questions.

Thanks Trenloe, I really do appreciate all the help - even if I do forget to say thanks now then.

dulux-oz
March 14th, 2014, 09:05
Thanks Trenloe, that was what I was after.

OK, next question: Is there a way to clear/reset the linkfield/windowreferencecontrol back to an "blank" state?

At the moment I've got:


<script>
function onDrop(nXPos,nYPos,oDragData)
if oDragData.getType() == "shortcut" and
oDragData.getShortcutData() == "imagewindow" then
[stuff happens];
else
setValue("","");
end
end
</script>

But this doesn't seem to work.

Thanks in advance

Nickademus
March 14th, 2014, 09:19
Tables have the functionality of removing a link. Might be able to find the code that does this and apply it to other links.

damned
March 14th, 2014, 13:15
Hi Guys,
... What I'd lick is...

now Im curious...

Trenloe
March 14th, 2014, 16:23
<script>
function onDrop(nXPos,nYPos,oDragData)
if oDragData.getType() == "shortcut" and
oDragData.getShortcutData() == "imagewindow" then
[stuff happens];
else
setValue("","");
end
end
</script>

But this doesn't seem to work.
Try setValue() instead of setValue("","")

dulux-oz
March 14th, 2014, 16:49
now Im curious...

Typo! :p

dulux-oz
March 14th, 2014, 16:50
Try setValue() instead of setValue("","")

Yup, tried that, still not work :(

Trenloe
March 14th, 2014, 16:52
Yup, tried that, still not work :(
After using that, if you close and re-open the window has the link gone? I'm wondering if it is a refresh issue.

Also try removing the link, closing FG and going back in and see if the link is still there?

I had a recent issue where changing the icon of a button was only refreshing if you closed FG and opened it again. JPG fixed that specific issue in 3.0.3.

Trenloe
March 14th, 2014, 16:52
Oh - and is the GM removing the link or a player?

dulux-oz
March 14th, 2014, 16:54
After using that, if you close and re-open the window has the link gone? I'm wondering if it is a refresh issue.

Also try removing the link, closing FG and going back in and see if the link is still there?

I had a recent issue where changing the icon of a button was only refreshing if you closed FG and opened it again. JPG fixed that specific issue in 3.0.3.

Yup, tired that as well - still a no go :(

GM

Trenloe
March 14th, 2014, 17:01
In the table entry that Nickademus references the linkfield (resultlink) is hidden if there is no link to it (setVisible(false)) and set to visible if there is link data, this is done via the updateDisplay function. Perhaps you could do something like that? Of course, the main issue here is that there is no obvious link icon to drag a link to.

<windowclass name="table_result">
<margins control="0,0,0,2" />
<script>
function onInit()
registerMenuItem(Interface.getString("table_menu_linkdelete"), "erase", 8);
updateDisplay();
end

function onMenuSelection(selection)
if selection == 8 then
resultlink.setValue();
end
end

function updateDisplay()
local bLink = not resultlink.isEmpty();
resultlink.setVisible(bLink);
end

function onDrop(x, y, draginfo)
if draginfo.isType("shortcut") then
resultlink.setValue(draginfo.getShortcutData());
return true;
end
end
</script>
<sheetdata>
<genericcontrol name="leftanchor">
<bounds>0,2,0,20</bounds>
<disabled />
</genericcontrol>
<genericcontrol name="base">
<anchored position="over" />
<script>
function onDrop(x, y, draginfo)
return window.onDrop(x, y, draginfo);
end
</script>
</genericcontrol>
<link_tableresult name="resultlink">
<anchored>
<top offset="2" />
<left parent="leftanchor" anchor="right" relation="relative" offset="5" />
</anchored>
<invisible />
<script>
function onValueChanged()
window.updateDisplay();
end
function onDrop(x, y, draginfo)
return window.onDrop(x, y, draginfo);
end
</script>
</link_tableresult>

Moon Wizard
March 14th, 2014, 17:33
I just tried it on my machine, by modifying the table record to test setValue() specifically. It's working as expected.

Looking at your code again, I think the problem is that you do not have "return true" at the end of your onDrop function. What I think is happening is that the value is actually being cleared in your onDrop event handler. However, since there is no return value, FG continues to process the drop event normally, which means that the link gets set again by the built-in windowreferencefield code.

Regards,
JPG

dulux-oz
March 15th, 2014, 04:57
I think the problem is that you do not have "return true" at the end of your onDrop function.

That was it - thanks Moon.

As always, its the little things that trip you up the most :)

Cheers