Simpe
June 4th, 2018, 15:47
Hi,
So I have a windowclass that I use in a windowlist. Each entry in the windowlist has a link to an ability.
The windowclass has 3 different instances of a button_checkbox. Now, I want these button_checkboxes to be visible or not depending on wether or not the ability has certain fields or not.
I've added a script-file associated with the windowclass used in the windowlist.
In that script-file, I've managed to extract the database module which is the ability that each instance in the windowlist references to. My problem is that I am unable to retrieve the window that is created for each entry in the windowlist.
I've tried using the windowlist.getWindows()-functionality, and I don't get the single-entry into the windowlist that I have. It seems to work better, although not flawless, if I have multiple items in the windowlist.
So here's some of the things in order to explain:
The windowclass used in the windowlist:
<windowclass name="charsheet_ability_list_item">
<margins control="0,0,0,2" />
<script file="scripts/charsheet_ability_list_item.lua"/>
<sheetdata>
<genericcontrol name="rightanchor">
<anchored height="0" width="0">
<top offset="2" />
<right />
</anchored>
</genericcontrol>
<button_idelete name="idelete">
<anchored to="rightanchor">
<top />
<right anchor="left" relation="relative" offset="-5" />
</anchored>
</button_idelete>
<linkfield name="shortcut">
<anchored to="rightanchor" width="20" height="20">
<top />
<right anchor="left" relation="relative" offset="-5" />
</anchored>
<class>charsheet_ability</class>
<description field="name" />
<readonly />
</linkfield>
<button_checkbox name="master_skilled">
<anchored to="shortcut" width="20" height="20">
<top/>
<right anchor="left" relation="relative" offset="-5" />
</anchored>
</button_checkbox>
<button_checkbox name="adept_skilled">
<anchored to="master_skilled" width="20" height="20">
<top/>
<right anchor="left" relation="relative" offset="5" />
</anchored>
</button_checkbox>
<button_checkbox name="novice_skilled">
<anchored to="adept_skilled" width="20" height="20">
<top/>
<right anchor="left" relation="relative" offset="5" />
</anchored>
</button_checkbox>
<string_textlistitem name="name">
<anchored to="rightanchor">
<top />
<left parent="" offset="5" />
<right anchor="left" relation="relative" offset="-5" />
</anchored>
<multilinespacing>20</multilinespacing>
</string_textlistitem>
</sheetdata>
</windowclass>
An example of the list I'm displaying:
<abilities>
<marksman>
<name type="string">Marksman</name>
<shortcut type="windowreference">
<class>reference_ability</class>
<recordname>ability.marksman</recordname>
</shortcut>
</marksman>
</abilities>
The list, using the list_column:
<list_column name="abilities">
<newfocus>name</newfocus>
<datasource>.abilities</datasource>
<class>charsheet_ability_list_item</class>
<acceptdrop>
<class>reference_ability</class>
</acceptdrop>
</list_column>
The code in the windowclass charsheet_ability_list_item:
function onInit()
local db_node = windowlist.getDatabaseNode()
local children = db_node.getChildren()
local windows = windowlist.getWindows()
for k,v in pairs(windows) do
Debug.console("Window:" .. tostring(k))
end
for k, v in pairs(children) do
Debug.console("DB Child: " .. tostring(k))
end
end
So the ACTUAL issue here is that the windowlist.getWindows() returns an empty table.
The db_node.getChildren() returns all the db-children that I want accurately. However, I'm unable to navigate to my three button_checkboxes and hide them.
All help is greatly appriciated!
Thanks,
Simon
So I have a windowclass that I use in a windowlist. Each entry in the windowlist has a link to an ability.
The windowclass has 3 different instances of a button_checkbox. Now, I want these button_checkboxes to be visible or not depending on wether or not the ability has certain fields or not.
I've added a script-file associated with the windowclass used in the windowlist.
In that script-file, I've managed to extract the database module which is the ability that each instance in the windowlist references to. My problem is that I am unable to retrieve the window that is created for each entry in the windowlist.
I've tried using the windowlist.getWindows()-functionality, and I don't get the single-entry into the windowlist that I have. It seems to work better, although not flawless, if I have multiple items in the windowlist.
So here's some of the things in order to explain:
The windowclass used in the windowlist:
<windowclass name="charsheet_ability_list_item">
<margins control="0,0,0,2" />
<script file="scripts/charsheet_ability_list_item.lua"/>
<sheetdata>
<genericcontrol name="rightanchor">
<anchored height="0" width="0">
<top offset="2" />
<right />
</anchored>
</genericcontrol>
<button_idelete name="idelete">
<anchored to="rightanchor">
<top />
<right anchor="left" relation="relative" offset="-5" />
</anchored>
</button_idelete>
<linkfield name="shortcut">
<anchored to="rightanchor" width="20" height="20">
<top />
<right anchor="left" relation="relative" offset="-5" />
</anchored>
<class>charsheet_ability</class>
<description field="name" />
<readonly />
</linkfield>
<button_checkbox name="master_skilled">
<anchored to="shortcut" width="20" height="20">
<top/>
<right anchor="left" relation="relative" offset="-5" />
</anchored>
</button_checkbox>
<button_checkbox name="adept_skilled">
<anchored to="master_skilled" width="20" height="20">
<top/>
<right anchor="left" relation="relative" offset="5" />
</anchored>
</button_checkbox>
<button_checkbox name="novice_skilled">
<anchored to="adept_skilled" width="20" height="20">
<top/>
<right anchor="left" relation="relative" offset="5" />
</anchored>
</button_checkbox>
<string_textlistitem name="name">
<anchored to="rightanchor">
<top />
<left parent="" offset="5" />
<right anchor="left" relation="relative" offset="-5" />
</anchored>
<multilinespacing>20</multilinespacing>
</string_textlistitem>
</sheetdata>
</windowclass>
An example of the list I'm displaying:
<abilities>
<marksman>
<name type="string">Marksman</name>
<shortcut type="windowreference">
<class>reference_ability</class>
<recordname>ability.marksman</recordname>
</shortcut>
</marksman>
</abilities>
The list, using the list_column:
<list_column name="abilities">
<newfocus>name</newfocus>
<datasource>.abilities</datasource>
<class>charsheet_ability_list_item</class>
<acceptdrop>
<class>reference_ability</class>
</acceptdrop>
</list_column>
The code in the windowclass charsheet_ability_list_item:
function onInit()
local db_node = windowlist.getDatabaseNode()
local children = db_node.getChildren()
local windows = windowlist.getWindows()
for k,v in pairs(windows) do
Debug.console("Window:" .. tostring(k))
end
for k, v in pairs(children) do
Debug.console("DB Child: " .. tostring(k))
end
end
So the ACTUAL issue here is that the windowlist.getWindows() returns an empty table.
The db_node.getChildren() returns all the db-children that I want accurately. However, I'm unable to navigate to my three button_checkboxes and hide them.
All help is greatly appriciated!
Thanks,
Simon