onDoubleClick Extension Function

I know this might be trivial for you guys, but how do I set the value of a label to the value of a power table cell on double click? Also, where can I find a list of scripting functions? Thanks.

Take a look at the Extension Function section for Power Tables in the manual.

As for this…

If the table and the label are at the same level, just add the following to the OnDoubleClick extension function of the table.

self.parent.getComponent('Label').text = value

This will take the value that is double clicked on, and write it to the text property of the label component named “Label”.

Ctrl+J will open the Component Scripting window, FYI.

Thanks, this is what I tried and didn’t work

event.source.parent.getComponent('Label').text = value 

There is no event object in the extension functions, you must use self instead.

Compare your script to the one posted by Stuart. Stuarts script should work.

It did, I was just showing him what I had tried before I posted the question

1 Like

Another Extension Function question:
Can system.gui.getParentWindow(event) be used in an extension function?
Such as:

	window = system.gui.getParentWindow(event)
	value = window.getRootContainer().customProperty

No, because there is no event object in extension functions. Use self instead.

	window = system.gui.getParentWindow(self)
	value = window.getRootContainer().customProperty

am i doing something wrong, self is not a EventObject.
Is there otherway to get the rootcontainer without to write self.parent.parent… and so on :slight_smile:

Java’s SwingUtilities can help. Place the following in a script module, shared.swing, perhaps:

from javax.swing import SwingUtilities
from com.inductiveautomation.factorypmi.application import FPMIWindow

def getParentWindow(component):
    return SwingUtilities.getAncestorOfClass(FPMIWindow, component)

Then in your extension function, you can do:

w = shared.swing.getParentWindow(self)
v = w.rootContainer.customProperty