I'm trying to detect whether a modifier key is being pressed when a city screen build option is clicked. This is what I tested in my CvMainInterface.py:
I would have expected these messages to fire whenever the shift key is pressed, but results varied widely:
Anyone have any idea why these keys are not being detected via handleInput and if there's anything I can do to fix it? I've tested this as a barebones mod with no other changes, so it's definitely not something else in my mod interfering.
Code:
def handleInput (self, inputClass):
'Handles input for this screen'
if CyInterface().shiftKey():
CyInterface().addImmediateMessage("Experiment 1 successful!", "")
if inputClass.isShiftKeyDown():
CyInterface().addImmediateMessage("Experiment 2 successful!", "")
if inputClass.getData() == int(InputTypes.KB_LSHIFT):
CyInterface().addImmediateMessage("Experiment 3 successful!", "")
I would have expected these messages to fire whenever the shift key is pressed, but results varied widely:
- Experiment 1 works whenever shift is held down and I click on a widget. This suits my needs for the shift key, but unfortunately there's no equivalent function for Ctrl or Alt.
- Experiment 2 works only on items already in the build queue (box in lower left of the screen), but nowhere else that I can find. Moreover, it only ever works with Shift, never with the equivalent Ctrl or Alt function.
- Experiment 3 doesn't work for any modifier key, no matter what is clicked.
Anyone have any idea why these keys are not being detected via handleInput and if there's anything I can do to fix it? I've tested this as a barebones mod with no other changes, so it's definitely not something else in my mod interfering.