PDA

View Full Version : onDelete ?



Oberoten
January 16th, 2009, 09:19
I have several windowlists on my charactersheet that all burns XP away as they are modified and added to.

But I just found out that when deleting an entry that still has an XP cost it tends to just remove the entry without re-calculating the XP used which might lead to loss of XP.

Is there a possible "OnDelete" function that can be called? Or how else could I do this?

- Obe

Tenian
January 16th, 2009, 11:21
onListRearranged

event function onListRearranged( listchanged )

If present, this function is called whenever the number or order of entries in the list changed.

Parameters
listchanged (boolean)
If the event causing the invocation of this event added or removed items from the list, the value will be true. Otherwise, false indicating that only the order of items was changed.


You can catch deletes with that. Unfortunately the item is already removed from the list. If you are just summing the XP for the list it should be reasonably easy to use this event to recalc the total

Oberoten
January 16th, 2009, 20:44
Manymany thanks. :) That solves it nicely. I'll add this immediately.

- Obe

Oberoten
January 16th, 2009, 20:58
Ehhh... WHERE do I add this?
When added to the windolist it did nothing, when added to the class it ... did nothing?

Tenian
January 16th, 2009, 22:20
It's listed as an event for windowlists:

https://www.fantasygrounds.com/refdoc/windowlist.xcp

Oberoten
January 16th, 2009, 22:26
I got it to work after all... :) Thanks for pointing me in the right direction. :) But I ended up rewriting a lot of my handling code for skills.

- Obe

Foen
January 17th, 2009, 07:12
The other potential approach, which can be placed anywhere in the script (say at the top window level) is to use the onChildUpdate event for the database node. It is called whenever a child node changes, and because it is a node-level event, you can add a handler to it from outside the list.

That said, the onListRearranged approach would have been my choice, and will work even if the windowlist entries are not bound to the database (which they sometimes aren't).

Foen