Text input script

I’m having a tough time combining these two scripts. What I want is to limit who can edit a string input (using the touch screen keyboard) in the PLC based on their user role. These scripts work separately but having a problem getting them together. Is there an easier way?

roles = system.security.getRoles() if 'Administrator' in roles or 'Operator' in roles: value = 1 event.source.parent.enabled = value else: event.source.enabled = 0


system.gui.setTouchscreenModeEnabled(1) if system.gui.isTouchscreenModeEnabled(): event.source.text = system.gui.showTouchscreenKeyboard(event.source.text) system.gui.setTouchscreenModeEnabled(0)

Where do you have the scripts right now? Which event handler?