detecting key presses without adding buttons to a panel
This is documented under: WinCC OA UI -> Module VISION -> Function keys
Is there a way to stop this somehow? Cause with the way it behaves now it's kind of pointless having it in the first place as anyone can press any F# key and stop whatever was processing before. All the usual methods of battling this, like software flags indicating that processing is ongoing don't really mean much, as another F# key press simply re-initialises the script.
I see potentially 2 solutions :
- Synchronized function inside your keypressed, thus your key listener cannot run twice.
- UI global var as semaphore
Thus you protect the execution of your script. Eventually you could build a queue global mapping, where key pressed add entry and run function and function itself clean mapping entry, combined with synchronized to avoid double execution.
Anyway I guess that with Synchronized and global UI var, it is up to your imagination
I've tried sticking "synchronized" in front of the main function in the keypressed.ctl, but that didn't work or change anything. At this stage I've gone with a dpconnect elsewhere and simply doing a dpSet inside the keypressed, writing the key int value to the DPE. This way the key press is handled outside the keypressed.ctl and it even buffers keypresses due to the nature of dpconnect. Not ideal, but seems to work fine.
Still I'm really surprised it works this way, it wouldn't be a big issue if there was a way to disable the F key interrupt within the keypressed.ctl (like you can on say microcontrollers), but I don't think there is...