User Defined Screen Objects

Recommended Posts

On a number of systems we create a 'User Defined Object' basically a class based object say for example a Motor graphic.

This motor graphic will utilize data structure within the HMI and be identical to the data structure used in the PLC.

So when adding a motor graphic to the screen we simply pass the base tag, and graphic pulls data from the base tag I.E

Base tag 'Motor1' Passed to graphic.

Indication for motor running would be Motor1.running etc.

Using this global object graphic allows very quick deployment and standardization across the project.

is this possible.

Link to comment
Share on other sites

Absolutely. Its usually done with groups (see 7.5 and 7.6 in the help), and then by creating your own properties (see 7.15) with the CreateProperty / CreateStringProperty functions in the OnLoad event of the group. I typically do all the work in the events of the group (View - Events), and then have them change properties for any contained controls to change behavior. That's because once the controls are in the group, you can't manipulate them outside of script without ungrouping. Just remember to name all the contained controls before grouping. From the group Event code, you should access the controls directly by name, i.e. instead of Component.myComponent.xxxx you'd just do Without this you'd get name conflicts as soon as you duplicated the control.

I've attached a sample user control. Its a menu button designed for page nav that displays a red background when its active. It is a group containing two controls, "TheButton" and "ThePanel" OnLoad has the following:


CreateStringProperty("Action",'page.strCurrentPage = " "')



local active = false

TheButton.strCaption = Label

Which creates three string properties, adds a listener (which allows multiple buttons to talk to each other), and sets the caption on the enclosed control named "TheButton" to whatever the label property is.

OnMessage contains:

if ((strMessage == "menubuttonpress") && (group == Param1))

active = false

ThePanel.Visible = active


This checks the message sent, and checks that the button is part of the desired group and if so, deactivates the button and hides ThePanel (which is the red background).

OnLButtonDown contains simply:


which activates the button.

SetActive is a user function of the group created by clicking Add in the event window. It contains:




// set active after message since message will clear active

active = true

ThePanel.Visible = active

The first line does whatever action was assigned to the button (changing the page). The second line simply updates and edit controls on pages. The third clears all other buttons, the fourth sets this button active and the last line displays the red background.

To edit the user properties of the component you have to open the Properties docking window by going to View-Properties.


Link to comment
Share on other sites

  • 3 weeks later...

Thanks for the File,

I am getting"

Problem Loading User Components, Not All components may have been loaded'

This is with V5.84 Build 1636,

Are user components incorporated into the saved file, or would they need copying to the clients machine also,

Can they be stored in a specific folder for 'User Objects'

Link to comment
Share on other sites

Ok Working Now Thanks,

Its probably a good idea to keep User Defined controls in a separate project for editing the master.

Also i guess with some work interfacing the mouse icon into the control is possible.

The example does not change the mouse pointer on hover,

But thanks for the starting point.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.