STAR TREK 2d20
  1. #1

    Hiding elements in windowlists

    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:
    Code:
    	<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:
    Code:
    			<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:
    Code:
    			<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:
    Code:
    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

  2. #2
    This issue has been solved! Moon Wizard showed me that the simplest solution for something like this was to copy the behavior of the delete-button that appears for every element in certain windowlists in the CoreRPG module.

    Said and done, I added a script to the button_checkbox (through creating a template) that handled exactly what I wanted for it to turn itself invisible or not. 5 minutes solution to a 4-hour problem. Thanks!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
DICE PACKS BUNDLE

Log in

Log in