PDA

View Full Version : Quick scripting question



Dachannien
May 25th, 2007, 15:50
When does a control's onSourceUpdate event function get called? Does it only get called when one of that particular control's sources gets updated?

If so, is it possible to specify a string control as the source for a number control, or is there a way to hook the onSourceUpdate event for a different control?

Dachannien
May 25th, 2007, 16:56
I think I managed to answer my own question. The first answer is yes, only when a control's sources get updated. The second answer is that you can specify a string control as the source for a number control, but you should then also provide an onSourceUpdate event function so that the default arithmetic operations don't try to work on the string source.

nezzir
May 26th, 2007, 00:34
I think I managed to answer my own question. The first answer is yes, only when a control's sources get updated. The second answer is that you can specify a string control as the source for a number control, but you should then also provide an onSourceUpdate event function so that the default arithmetic operations don't try to work on the string source.

Yeah... I was gonna... say that.

Dachannien
May 27th, 2007, 08:16
Actually, I think I was wrong. There is no onSourceUpdate event function. The d20 default ruleset implements a function called onSourceUpdate for the linkednumber template class, but this function gets called as a result of being assigned (in a roundabout way) to the onUpdate handler.

When using a linkednumber as the template for a control, however, what I said above actually does apply.