onDragStart event not being captured for templated buttoncontrol
I'm running into an issue with the onDragStart event that should be attached to a buttoncontrol that I have in my extension. Actually, the event works fine when I define the control directly in my windowclass, but if I attempt to wrap everything up into a reusable template which I then reference in the same windowclass, I can't get the event to fire any more. Other events (onButtonPress, onClickDown, even onDrag) still seem to occur correctly, just not the one I need for the behavior I want.
Below is a lot of xml and lua snippets and chat log output documenting the problem. Feel free to skip over it if I'm missing something obvious (I almost hope I am!)
The following xml contains both a fully defined version of the control (highconcept_buttoneffect) which correctly captures onDragStart, followed by a templated one (trouble_buttoneffect) which does not. They both reference the same script file and should be identical as far as the final control definition goes. This all is meant to be merged with the charsheet_main windowclass defined in record_char_main.xml of the Fate Core ruleset—the <string_labeled> controls are part of the original ruleset, and the ones whose names end in _buttoneffect are original to my extension.
Code:
<root>
<windowclass name="charsheet_main" merge="merge">
<sheetdata>
<string_labeled name="highconcept" >
<anchored offset="15,13">
<right offset="-38" />
</anchored>
</string_labeled>
<buttoncontrol name="highconcept_buttoneffect">
<anchored to="highconcept" width="20" height="20">
<top />
<left anchor="right" relation="relative" offset="2" />
</anchored>
<icon normal="button_action_effect" pressed="button_action_effect_down" />
<script file="common/scripts/aspect_effect.lua" />
</buttoncontrol>
<string_labeled name="trouble">
<anchored offset="15,43">
<right offset="-38" />
</anchored>
</string_labeled>
<button_aspecteffect name="trouble_buttoneffect">
<anchored to="trouble"/>
</button_aspecteffect>
</sheetdata>
</windowclass>
</root>
This is my template, defined in another file in my extension (common/template_common.xml, if it matters)
Code:
<root>
<template name="button_aspecteffect">
<buttoncontrol>
<anchored width="20" height="20">
<top />
<left anchor="right" relation="relative" offset="2" />
</anchored>
<icon normal="button_action_effect" pressed="button_action_effect_down" />
<script file="common/scripts/aspect_effect.lua" />
</buttoncontrol>
</template>
</root>
So why do I think the onDragStart event isn't being captured? I have the following functions which output debug statements to the chat window defined in my script file which is used by both controls. Note that the onDrag Debug statement is commented out, because it's incredibly spammy with how often it gets called, but it does appear for both controls when it's uncommented.
Code:
function onDragStart(button, x, y, draginfo)
Debug.chat("onDragStart", getName(), button, x, y, draginfo);
return true;
end
function onDrag(button, x, y, draginfo)
--Debug.chat("onDrag", getName(), button, x, y, draginfo);
return true;
end
function onClickDown(button, x, y)
Debug.chat("onClickDown", getName(), button, x, y);
return true;
end
function onButtonPress()
Debug.chat("onButtonPress", getName());
return true;
end
With these functions set up, when I click and release on both controls, I see the onClick and on onButtonPress events captured as I would expect.
Quote:
s'onClickDown' | s'highconcept_buttoneffect' | #1 | #9 | #3
s'onButtonPress' | s'highconcept_buttoneffect'
s'onClickDown' | s'trouble_buttoneffect' | #1 | #12 | #11
s'onButtonPress' | s'trouble_buttoneffect'
When I try dragging both though, I only get the onDragStart for the first, inline defined control (highconcept_buttoneffect) and not the second, templated one (trouble_buttoneffect).
Quote:
s'onClickDown' | s'highconcept_buttoneffect' | #1 | #6 | #15
s'onDragStart' | s'highconcept_buttoneffect' | #1 | #6 | #15 | dragdata = { type = s'none', desc = s'', #slots = #1, slot = #1, string = s'', num = #0, dice = { }, shortcut = { }, token = { prototype = , instance = }, custom = nil }
s'onClickDown' | s'trouble_buttoneffect' | #1 | #12 | #10
(...nothing else)
When I uncomment the debug line in the onDrag event, I even see that one happening for both controls, just not the "start" event for the drag.
Quote:
s'onDrag' | s'highconcept_buttoneffect' | #1 | #-366 | #213 | dragdata = { type = s'none', desc = s'', #slots = #1, slot = #1, string = s'', num = #0, dice = { }, shortcut = { }, token = { prototype = , instance = }, custom = nil }
s'onDrag' | s'trouble_buttoneffect' | #1 | #-284 | #109 | dragdata = { type = s'none', desc = s'', #slots = #1, slot = #1, string = s'', num = #0, dice = { }, shortcut = { }, token = { prototype = , instance = }, custom = nil }
And finally, just to rule out the possibility that it's the control positions or anything like that, when I switch the approach for both controls, I get the reverse behavior: the highconcept_buttoneffect control does not capture onDragStart when defined as a templated control and the trouble_buttoneffect control does when defined inline.
At this point I'm completely stumped. I would appreciate any help or insight, even if it's just to point out how dumb I am for missing something obvious, or that this is intended and I'm supposed to define my controls inline. Thanks in advance.