Button writing to Custom property

I simply want to write the beginning of a tag path to a custom property using a button.

Based on 3 different buttons on the screen, when pressed, I want it to change the script property to a different tag path



Or to be done with a dropdown selection. I have this script elsewhere, being used for a dropdown selection, but it swaps windows and passes the custom property in. I do not think it needs to be this complicated to execute what I need.

Why don’t you just write directly to the custom property?

Event.source.parent...GasWells = newValue
Where … Is the path to the root container

1 Like

I was unsure of the correct syntax; but I am still having issues and what part exactly to include from the path and how to enter it. I have tried many ways to try and get it right.

event.source.parent.PopUps.Production.MeterScreeenSkilletHill.Gas Flow Trending.GasWells = “GasWellSites/SkilletHill/SkilletHill_Meter”

PopUps/Production/MeterScreeenSkilletHill is the path to the window and the root container is named “Gas Flow Trending”

You can’t directly access arbitrary nested components as properties (in Vision, at least; Perspective is a different ballgame) - you need to drill down using successive getComponent calls, like this:

event.source.parent.getComponent("PopUps").getComponent("Production").getComponent("MeterScreeenSkilletHill").getComponent("Gas Flow Trending").GasWells = “GasWellSites/SkilletHill/SkilletHill_Meter”

You should just need a string of .parent to get to the root container. You shouldn’t need to use getComponent as the parameters you’re accessing are from the root container.
But you should be able to pick the GasWells property on root container using the component property picker in the script editor (top right icon panel).

E.g. It might be

Also, it would actually be better if you used an expression binding that bound the GasWells value to the drop down selectedLabel property. That way it’s bound to an expression, and not simply written to when an event is fired, which can sometimes mean the value isn’t written to it if the propertyChange event doesn’t fire. For example in the designer when you have it in design mode and you manually write to the dropdown selectedValue or selectedLabel property

Uhm, the button and the target property aren’t in the same window, are they?

If so, you need to get a reference to the target window like so:

w = system.gui.getWindow("path/to/my/window")
w.rootContainer.someProperty = someValue
1 Like

event.source.parent.GasWells = ‘GasWellSites/SkilletHill/SkilletHill_Meter’
event.source.buttonBG = 204,255,204
event.source.parent.getComponent(“ButtonMeterTotal”).buttonBG = 251,250,249
event.source.parent.getComponent(“ButtonMeter2”).buttonBG = 251,250,249

This is what I have working, I understand wanting to bind it rather than just write to it, I may come back to that later. For now this works.
Also, I think I stumbled upon the “buttonBG” to change the background color.
This is coming up again; I want to use a button to write to a components visibility property.
Is there a list of each property and the corresponding string needed?
ie. Background Color = buttonBG

I want the visibility property of an easy chart
so far :: event.source.parent.getComponent(“Easy Chart 1”).visible = 1

Ok I must have been making a mistake before, because .visible is correct. The list, or where to find more information would be very useful though, for other properties that may vary as the background color, or an explanation.

Properties are usually called out in the manual for components. A faster way for many of them as well is to hover over them in the property editor in the designer. It usually will say what the scripting name of the property is.

Great, thank you for the hover method. Very easy.