PDA

View Full Version : UI Problem



Bidmaron
March 24th, 2014, 02:07
OK, this is my first extension where I need to actually mess with new UI components. I did fine up to the point where I had to put in a check on/off button control. Now I cannot get the button to show up with any combination of the anchor tags I've been able to try. Below is a screen shot of what I'm getting right now. The check on/off button (for this data, it would be off, or an empty circle) I want to show up to the left of "Multiply Selectable".
6308

Here is my window code:(the red sets up the area with the 'Multiply Selectable' label, the line above it, and the button.

<sheetdata>
<anchor_column name="columnanchor" />

<label_column name="alttype_label">
<static textres="Ref_Label_FeatType" />
</label_column>
<string_columnhc name="alttype">
<script>
function onInit()
if super.onInit then
super.onInit();
end
local w = addBitmapWidget("solidblack");
w.setPosition("topright", -1,5);
end
</script>
</string_columnhc>

<label_column name="prerequisites_label">
<static textres="ref_label_prereq" />
</label_column>
<string_columnh name="prerequisites">
</string_columnh>

<line_column name="line_benefit" />

<label_column name="benefit_label">
<static textres="ref_label_benefit" />
</label_column>
<ft_columnh name="benefit">
<anchored>
<top parent="columnanchor" anchor="bottom" relation="relative" offset="27" />
</anchored>
<separator>line_benefit</separator>
</ft_columnh>

<line_column name="line_normal" />

<label_column name="normal_label">
<static textres="ref_label_normal" />
</label_column>
<ft_columnh name="normal">
<anchored>
<top parent="columnanchor" anchor="bottom" relation="relative" offset="27" />
</anchored>
<separator>line_normal</separator>
</ft_columnh>

<line_column name="line_mult" />
<label_column_right name="mult_label">
<static textres="Ref_Label_Mult" />
<anchored>
<top parent="columnanchor" anchor="bottom" relation="relative" offset="0" />
</anchored>
</label_column_right>
<button_checkboxh name="mult">
<separator>line_mult</separator>
<anchored to="mult_label" position="left" offset="30,30" />
</button_checkboxh>

<line_column name="line_special" />

<label_column name="special_label">
<static textres="ref_label_special" />
</label_column>
<ft_columnh name="special">
<anchored>
<top parent="columnanchor" anchor="bottom" relation="relative" offset="27" />
</anchored>
<separator>line_special</separator>
</ft_columnh>
</sheetdata>


This is the template for button_checkboxh:(where button_checkbox is a CoreRPG template in the template_column.xml file)

<template name="button_checkboxh">
<button_checkbox>
<script file="scripts/button_checkbox.lua" />
</button_checkbox>
</template>


Here is the code in button_checkbox.lua: (this is working since the line above the label and the label are showing up (plus, the debugs are printing out okay))
-
-
-- Please see the license.html file included with this distribution for
-- attribution and copyright information.
--

function onInit()
self.update(isReadOnly());
end

function update(bReadOnly, bForceHide)
local bLocalShow;
if bForceHide then
bLocalShow = false;
else
bLocalShow = true;
if bReadOnly and not nohide then
bLocalShow = false;
end
if nohide then
bLocalShow=true;
end
end
Debug.chat("blocalshow",bLocalShow,"readonly",bReadOnly);
setReadOnly(bReadOnly);
setVisible(bLocalShow);

local sLabel = getName() .. "_label";
if window[sLabel] then
Debug.chat("doing label");
window[sLabel].setVisible(bLocalShow);
end
if separator then
if window[separator[1]] then
Debug.chat("doing line");
window[separator[1]].setVisible(bLocalShow);
end
end

if self.onVisUpdate then
self.onVisUpdate(bLocalShow, bReadOnly);
end

return bLocalShow;
end



I think my problem is that I just don't understand all the anchoring stuff very well. I have had great success adding standard labels and fields, but the moment I'm trying to add this very straightforward button control.....

Thanks for anyone who can tell me the anchor trick I'm missing.

Trenloe
March 24th, 2014, 02:31
Anchoring using "left" will be in the middle of the left side of the control anchored to - sharing the two corners (top left and bottom left), see the "Using the anchoring shorthand notation" section here: https://www.fantasygrounds.com/modguide/windowing.xcp Using an offset of 30,30 means that the checkbox will be 30 from the left horizontally and 30 down vertically - which may be where the issue is as your next control have a relative vertical offset of 27 and could well be covering the checkbox control. Try an offset of 30,0.

Bidmaron
March 24th, 2014, 02:34
Trenloe, I tried 30,0 first, and that didn't work either. I have studied the hello out of that entire writeup and still find it a little confusing. Anyway, 30,0 doesn't work either. Any other ideas?
My understanding is that positive offsets work to increase separation in the specified direction, and negative reduce the separation (although how do you get smaller than 0,0?)

Trenloe
March 24th, 2014, 02:51
Grasping at straws here - try 10,0. Then start going negative: -10, 0.

Bidmaron
March 24th, 2014, 03:11
NOTHING WORKS!!! Thanks for trying, Trenloe.

Trenloe
March 24th, 2014, 03:26
Can you send me your extension so I can try it myself?

Bidmaron
March 24th, 2014, 03:37
Trenloe, I just discovered a minor issue with the docs, as button field is missing, but it clearly is the field implementation of button control. Extension6309

OK, here is my 6310 database, which contains a character 'Butthead' who has some abilities on his Ability page for testing.

Since the mult and stack fields are not normally displayed, I want them to display when you go to edit the record. So, to see how the thing works, just go to the ability tab of the character sheet and open the 'No Trace' ability.

This will show you the reference feat window with an icon in the upper right showing it is currently protected. Click the scroll icon and a quill will show up indicating you are in edit mode. This is when all the empty fields and the mult/stack fields are supposed to show up (and they all do except for the buttons).

You will note that I added in a button for stack bypassing my code just to make sure that wasn't the problem, but for some reason the buttons won't show up.

Bidmaron
March 24th, 2014, 03:59
Oh, disregard the 'solidblack' bitmapwidget added to the Type field. I was just experimenting with how to use widgets and forgot to take that out.

Trenloe
March 24th, 2014, 04:22
Use this:

<button_checkboxh name="mult">
<anchored to="mult_label" position="left" offset="30,0" width="12" />
</button_checkboxh>
Anchoring to the "left" inherits the height of the control being anchored to, but not the width. This size needs to be specified within the <anchored> tag as the 0 width coming from the left anchor will override any width set in the control or any inherited templates.

Bidmaron
March 24th, 2014, 04:24
You da man again, Trenloe!

That makes sense, of course.

Bidmaron
March 24th, 2014, 04:28
Thanks, Trenloe. That worked. I'm back in business now. I doubt I'd have ever figured that out without your help!