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
-
@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()
-
Wait, um, after i added
print()
the pressesChange is not activating -
@yaley ok. And did you trace, sure that changed def is called?
Sorry: was typing while your previous post was coming
-
@cvp i dont think that that def was called :(
-
@yaley but do you really need it? The doc says it is called if you change something in your key press, like force. If you know which key is down and up, and when, you have all you need, haven't you?
-
Yep! Maybe…. No need!
-
@cvp But the main problem is just when arrow keys will happen, just like umm i give you an example:
I am detecting keys withui.Textfield()
And now i start pressing left arrow key. So in the input it goes left ( the selection bar ), but if the right arrow keys joined the right arrow key, the selection bar of input still goes left. -
And, also, can
vi.View().get_key_commands()
andui.View().key_command(sender)
detect keyup? if can, then i can make -
@cvp can it?
-
This post is deleted! -
@yaley sorry, was driving to France for some days, not able to answer
-