Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Check multi-keys press
-
@DOGGY It’s ok :)
-
@cvp oops that’s my wrong, but after changing it to
True
, it’s still not working, everything turns True, let me see the documentation carefully again.After the key changed, the activeKey turns True, but then it will forever True, until next keyup
-
@yaley don't forget that presses is a kind of array with eventually multiple keys thus perhaps not only check [0]
-
@YaleY that would be a hard one…..
-
@cvp so what should i do now???? Can you show me the code with successful running?
-
@yaley said
Can you show me the code with successful running?
Ho no, you are further than me. I only try to think about it.
When you press the right arrow, your first key is still pressed? -
@cvp yes, but the problem is when the second press joined
CustomViewController_pressesChanged_withEvent_()
didnt run about it -
@cvp You’re method is correct, just i am stupid, i typed wrongly, i set the variable to True in the
pressesEnded
defXD
-
@yaley right, just tested
-
Wait no, why??? Why my first test is correct and then the second test is not working?????
-
@yaley for me, changed not called
If you change something in a created class, restart Pythonista -
@cvp here’s my code, I’ve tried to restart Pythonista
def CustomViewController_pressesBegan_withEvent_(_self, _cmd, _presses, event): global activeKeys presses = ObjCInstance(_presses).allObjects() keyCode = presses[0].key().keyCode() activeKeys[keyCode] = True def CustomViewController_pressesEnded_withEvent_(_self, _cmd, _presses, event): global activeKeys presses = ObjCInstance(_presses).allObjects() keyCode = presses[0].key().keyCode() activeKeys[keyCode] = False def CustomViewController_pressesChanged_withEvent_(_self, _cmd, _presses, event): global activeKeys presses = ObjCInstance(_presses).allObjects() keyCode = presses[0].keyCode() activeKeys[keyCode] = True
-
@yaley you should add some print in each method to check if called
-
-
@yaley only began is called once with left arrow, second with right arrow
Thus, forget changed, and all is ok because two keys imply 2 calls to began
-
@cvp thanks it solved!!!
-
@cvp looks like i found the problem, if in the changed def, i set
activeKeys[keyCode] = presses[0].key().keyCode()
it doesn’t work, but if i setactiveKeys[keyCode] = presses[0].keyCode()
then it works :) -
@yaley sorry, perhaps I (or my eyes) become too old, but I don't see the difference
-
@cvp no it’s my wrong again xD They’re absolutely no difference before, lol
-
@cvp I’ve already changed it, read it again :D The difference is
[0].key().keyCode()
and[0].keyCode()