PDA

View Full Version : Trouble with Windowlist



PneumaPilot
November 22nd, 2008, 07:16
I am having a hard time making my own windowlist control. Specifically, I can't get the thing to be able to add a new element to the list if there are no current elements in the list.

If I position my windowlist "over" another control, an empty entry will show up. At that point, I can add data and even create new elements. After doing this, I can change the position of the thing back to where I really want it, and all of my elements will appear where they are supposed to for that one record (in this case, for one NPC in the NPC window). But if I create an entirely new NPC, then my windowlist goes invisible again and I cannot click anywhere to add a new element.

Forgive me if this is hard to understand. It's very late and my mind is mush from messing with this.

Foen
November 22nd, 2008, 08:42
It would be helpful to know how you are anchoring the list.

Windowlists need to be anchored or positioned so that at least part of them is accessible when empty (they mustn't have zero height or width). If you don't do this, there is no exposed part of the list to right-click on.

Typically a generic control is used as a frame and the windowlist is positioned over the generic control, but you can also position the windowlist relative to its containing window or to another control.

Foen

Brenn
November 22nd, 2008, 12:34
To add to what Foen said- Here is a stripped down version of the components that make up a windowlist that I am using:



<!-- The windowclass definition for the individual entries in the windowlist. -->
<windowclass name="reign_weaponlistitem">
<sizelimits>
<minimum>
<height>20</height>
</minimum>
</sizelimits>
<script file="scripts/reign_weaponlistitem.lua"></script>
<sheetdata>
<!--Whatever controls for the windowlist entries -->
</sheetdata>
</windowclass>

<!-- The windowclass definition that contains the windowlist. Note the generic control I use to anchor the windowlist to. -->
<windowclass name="reign_custom_weapons">
<placement>
<size>
<width>252</width>
<height>611</height>
</size>
</placement>
<nodelete />
<datasource>reigncustomweapons</datasource>
<sheetdata>
<genericcontrol name="weaponlistframe">
<bounds>10,15,494,390</bounds>
<frame>
<name>sheetgroup</name>
</frame>
</genericcontrol>
.
.
.
<windowlist name="weaponlist">
<anchored>
<to>weaponlistframe</to>
<position>over</position>
<offset>-12,-9</offset>
<top>
<parent>weaponlistframe</parent>
<offset>25</offset>
</top>
</anchored>
<datasource>.weaponlist</datasource>
<class>reign_weaponlistitem</class>
<allowcreate />
<allowdelete />
<script file="scripts/reign_weaponlist.lua"></script>
</windowlist>
</sheetdata>
</windowclass>


Edited for brevity ;)

PneumaPilot
November 22nd, 2008, 22:49
Okay, so say I have actually 3 different windowlists that need to come one after another in the NPC window, separated only by headings. If I establish a genericcontrol to anchor the things to, will that space grow as elements are added to the list, or will that even matter?

I'll give it a try. Thanks for the help. I think I'm going to do a genericcontrol with no frame.

Brenn
November 22nd, 2008, 22:56
No it won't grow beyond the bounds of the control it is anchored to, but the windowlist is scrollable by default with the wheel and you can add a scroller button if you wish.

PneumaPilot
November 23rd, 2008, 00:02
Hmmm, well, that's not cool. Soooo, if I anchor it to the previous control for positioning purposes, I can't click anywhere to add a new element, but if I anchor it over a genericcontrol, then it may scroll within a tiny space and look ugly?

Brenn
November 23rd, 2008, 00:13
Well you could anchor the generic control to the previous control and anchor the list to the generic control. If you want it to autosize you'll have to do that to the generic control in script. I've never done that with a windowlist, but I have with other things, so I'll bet it can be done.

Foen
November 23rd, 2008, 05:24
I think you could achieve what you want using script. Window lists have an event called onListRearranged, which is invoked whenever the contents change. Within a handler for that event, check to see if the number of items in the list is zero - if that is the case, then set the list height to a respectable minimum - if the number is non-zero then allow the list to auto-size.

The appropriate method for setting the height is setAnchoredHeight, which works only if one of the top *or* bottom anchor is set. I think you can pass nil to setAnchoredHeight to reset it and allow auto-sizing.

The piece of code therefore looks a bit like:



if (#getWindows())==0 then
setAnchoredHeight(minheight);
else
setAnchoredHeight(nil);
end


You can then anchor each list to the one above it and yet still have space to add items when the list is empty.

Hope that helps

Foen

PneumaPilot
November 28th, 2008, 23:29
Okay, so this stuff is killing my enthusiasm for this endeavor. Foen, are you saying to just insert a code like that into the windowlist onListRearranged event and then make the windowlist just an element on the sheet with no genericcontrol to anchor to? Or are you saying to do the anchor over the genericcontrol and put the code in also? Could I just use a <sizelimits> and be done? I don't get how this thing is detecting for clicks...

PneumaPilot
November 28th, 2008, 23:39
Ah, YES! Foen, that worked beautifully. I don't know where you work or what you do, but you need a raise! Aha! I can get working on this blasted thing again! Thank you so much!

Foen
November 29th, 2008, 06:20
My pleasure!