Easy Chart mode not changing with setMode

We are no longer allowed to use right-click on Ignition client computers. IT uses Secure Desktop 12 blocked right-click. No convincing them otherwise.

I’ve found some other threads about this, but they had additional errors or were calling setMode incorrectly. I looks like I’m doing it correctly and not even getting errors. I can add print statements and it looks like the script is running.

This is the script for the actionPerformed event for the Settings Menu button above. The menu works and I can see the debug prints when i click X-Trace for example.

The Easy Chart name is indeed “Easy Chart”.

I’m using an integer to change the mode.

from javax.swing import JPopupMenu, JMenu, JMenuItem, JSeparator
from java.awt.event import ActionListener

chart = event.source.parent.getComponent('Easy Chart')

# MENU CALLBACK HELPER
class MenuAction(ActionListener):
    def __init__(self, func):
        self.func = func
    def actionPerformed(self, e):
        self.func()

# MODE CHANGE
def setSpan():
    chart.setMode(1)

def setZoom():
    chart.setMode(0)

def setMark():
    chart.setMode(3)

def setXTrace():
    chart.setMode(4)
    print("chart set to Mode(4) - X-Trace")

# RESET AXES
def resetAxes():
    chart.axes = chart.axes
    chart.repaint()

# BACKGROUND
def setBlack():
    from java.awt import Color
    chart.background = Color.black
    chart.plotBackground = Color.black
    chart.repaint()

def setWhite():
    from java.awt import Color
    chart.background = Color.white
    chart.plotBackground = Color.white
    chart.repaint()

# BUILD MENU
menu = JPopupMenu()

# MODE SUBMENU
modeMenu = JMenu("Mode")

item = JMenuItem("Span")
item.addActionListener(MenuAction(setSpan))
modeMenu.add(item)

item = JMenuItem("Zoom")
item.addActionListener(MenuAction(setZoom))
modeMenu.add(item)

item = JMenuItem("Mark")
item.addActionListener(MenuAction(setMark))
modeMenu.add(item)

item = JMenuItem("X-Trace")
item.addActionListener(MenuAction(setXTrace))
modeMenu.add(item)

menu.add(modeMenu)

# RESET AXES
item = JMenuItem("Reset Axes")
item.addActionListener(MenuAction(resetAxes))
menu.add(item)

menu.add(JSeparator())

# BG SUBMENU
bgMenu = JMenu("Background")

item = JMenuItem("Black")
item.addActionListener(MenuAction(setBlack))
bgMenu.add(item)

item = JMenuItem("White")
item.addActionListener(MenuAction(setWhite))
bgMenu.add(item)

menu.add(bgMenu)

# POPUP MENU LOCATION (UNDER BUTTON)
menu.show(event.source, 0, event.source.height)

I figured I’d get some error at least. I saw a thread that said I might need to click the chart afterwards but that doesn’t make a difference. This seems so easy compared to stuff I’ve already done and I’m not sure what’s wrong.