MappView CompoundWidget Events and Actions

Automation Studio 6.3.4, mappView 6.5.0

Im trying to create a compound widget for mappView. The purpose of which is to act as an axis selector. It displays an AxisName (String, directly set) and AxisValue (Current Axis Pos, bind variable). I will be using this to create a jog page with up to 16 axes. All of my axes are in a single array and chosen by a selected axis index. Basically i want to have it where when one of the custom widgets i clicked on it sets a session var LastAxisSelected to the AxisIndex set inside of the widget. When selected the backgound color of AxisValue should be yellow, when not selected it should be grey. Then whenever LastAxisSelected changes value i want all instances of the compound widget to internally compare their AxisIndex with LastAxisSelected and update the color of AxisValue accordingly.

I realize that i cant access a session variable from inside of a compoundwidget so i added a parameter SelectedAxisIndex to it. I do realize that i will need to bind this manually for every instance of the compound widget i create.

Im trying to use a little external bindings or event bindings as possible since this can go up to 16 axes. I was able to make the widget with the needed properties but im having issues getting the correct bindings or actions to make this possible. Any help would be much appreciated.

Hello!

I think I understand what you’re trying to do, but correct me if I misunderstood.

You want to drive an event based on the value change of your selected axis, that axis is one of a few datapoints mapped externally to the compound widget. How I’ve been taught to do this is by creating invisible widgets that drives the event. I create an image list at 0,0 and make it invisible, then I bind my numeric value to it, make the default -1, and in the event bindings I use “SelectedIndexChanged“ to drive the event.

I’ll paste an example below, but I highly recommend if you are going to do anything complex in mappview that you move to eventscripts instead of the xml editor for events. It was released in mappview 6.3 and I’ve rewritten almost all of my widgets using it.

My example is for changing the visibility of a label and rectangle based on a numeric value, but concept is the same regardless of widget type

Declare widgets

<Widget xsi:type="widgets.brease.Rectangle" id="recLoadDisabled" top="0" left="0" width="600" height="405" zIndex="30" borderStyle="inset" borderWidth="3px" cornerRadius="10px" backColor="rgba(128, 128, 128, 1)" opacity="0.75"/>
   	
<Widget xsi:type="widgets.brease.ImageList" id="invisLoadDisabled" top="0" left="0" selectedIndex="-1" zIndex="49" imageList="['']" visible="false"/>

Bind the invisible widget to your datapoint

	<Properties>
		<Property xsi:type="StructureBindableProperty" name="Data" type="WLCXFR_INTERFACES_typ" readOnly="false">
			<Description>Description will be shown in property grid.</Description>
			<Mappings>
				<!-- invisible widgets for internal mapping -->
				<Mapping widget="invisLoadDisabled" type="Number" property="selectedIndex" mode="twoWay" memberPath="LoadInterface.interfaceEnabled" mapToNode="false"/>
			</Mappings>
		</Property>
  </Properties>

Then create an event for the invisible widgets index change

  <EventBindings>
    <!-- source and target can only be widgets within the compound widget. -->
	<EventBinding id="LoadDisabled">
		<Source xsi:type="widget.Event" widgetRefId="invisLoadDisabled" event="SelectedIndexChanged"/>
		<EventHandler condition="selectedIndex = 1">
			<Sequence>
				<Step order="0">
					<Action>
						<Target xsi:type="widget.Action" widgetRefId="recLoadDisabled">
							<Method name="SetVisible" value="false"/>
						</Target>
					</Action>
				</Step>
				<Step order="1">
					<Action>
						<Target xsi:type="widget.Action" widgetRefId="lblLoadDisabled">
							<Method name="SetVisible" value="false"/>
						</Target>
					</Action>
				</Step>
			</Sequence>
		</EventHandler>
		<EventHandler condition="selectedIndex = 0">
			<Sequence>
				<Step order="0">
					<Action>
						<Target xsi:type="widget.Action" widgetRefId="recLoadDisabled">
							<Method name="SetVisible" value="true"/>
						</Target>
					</Action>
				</Step>
				<Step order="1">
					<Action>
						<Target xsi:type="widget.Action" widgetRefId="lblLoadDisabled">
							<Method name="SetVisible" value="true"/>
						</Target>
					</Action>
				</Step>
			</Sequence>
		</EventHandler>
	</EventBinding>

That should accomplish the style change you are trying to do. If you’d like an example of the same in event scripts let me know.

1 Like

Is event scripts a utility? Or is it more like make the widget as a normal content then add events to it. Then copy those events to the compound widget.

You’ll layout the widget in xml as you have been, but after you declare the widgets you’ll be able to access them in an eventscript and use javascript to do all the actual code for your events.

to add one, click your compound widget in the logical view, then go to the toolbox on the right hand side of the screen and click eventscript. It will auto link to the compound widget and intellisense will allow you to do autocomplete. start by typing “widgets.“ without the quotes and it will bring up a list of widgets from the compount widget.