PDA

View Full Version : stringfield onClickRelease?



celestian
August 24th, 2017, 17:01
So, I've been trying to pop up a window and while it works it puts the window BEHIND my selection window. I want it to pop infront. I'm thinking it's because the window opens with "onClickDown()"?

Is there an onClickRelease type function for stringfield? I've tried to find something on this in the docs page but had no luck. Infact I only know the options onClickDown and onDoubleClick work is because I found it in existing ruleset code elsewhere.

Here is the template where I call the function that opens the window.


<template name="class_advancement_label">
<stringfield>
<script>
function onClickDown(x,y)
return window.advancementEditor();
end
function onDoubleClick(x,y)
return window.advancementEditor();
end
</script>
<multilinespacing>12</multilinespacing>
<anchored to="rightanchor">
<top />
<left parent="" offset="4" />
<right anchor="left" offset="-4"/>
</anchored>
<frame name="fielddark" offset="7,8,7,8" />
<stateframe>
<hover name="rowshade" offset="7,8,7,8" />
</stateframe>
<cursor hover="hand" />
<readonly />
</stringfield>
</template>


This is the code for the window that is opening behind. I even tried the bringToFront() as well. I also tried a setFocus for a field in the editor window in the window itself (int onInit()).



function advancementEditor()
local w = Interface.openWindow("class_advancement_editor", getDatabaseNode());
w.bringToFront();
end


A button would seem to be the best way to do this but I can't seem to find a a way to set the text of the button as something non-static. I need to be able to change the state text="" on the fly. This does pop up the window as I am wanting but... anyone know how to change text?



<template name="class_advancement_label">
<button_text_sm>
<script>
function onButtonPress()
return window.advancementEditor();
end
</script>
<state text="DEFAULT TEXT" />
<stateframe>
<hover name="rowshade" offset="7,8,7,8" />
</stateframe>
<cursor hover="hand" />
</button_text_sm>
</template>

celestian
August 24th, 2017, 19:55
Okay, so I'm an idiot. It seems to be all about the "return true;" missing ... woops.



<template name="class_advancement_label">
<label>
<script>
function onClickRelease( button, x, y )
window.advancementEditor();
return true;
end
function onClickDown( button, x, y )
return true;
end
</script>
<multilinespacing>12</multilinespacing>

<frame name="fielddark" offset="7,8,7,8" />
<stateframe>
<hover name="rowshade" offset="7,8,7,8" />
</stateframe>
<cursor hover="hand" />
<center />
</label>
</template>