omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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

    Pythonista
    viewcontroller keypress objcutil
    4
    42
    5524
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • yaley
      yaley last edited by

      @cvp yes, but the problem is when the second press joined CustomViewController_pressesChanged_withEvent_() didnt run about it

      cvp 1 Reply Last reply Reply Quote 1
      • yaley
        yaley last edited by

        @cvp You’re method is correct, just i am stupid, i typed wrongly, i set the variable to True in the pressesEnded def

        XD

        1 Reply Last reply Reply Quote 0
        • cvp
          cvp @yaley last edited by

          @yaley right, just tested

          1 Reply Last reply Reply Quote 0
          • yaley
            yaley last edited by

            Wait no, why??? Why my first test is correct and then the second test is not working?????

            cvp 1 Reply Last reply Reply Quote 0
            • cvp
              cvp @yaley last edited by

              @yaley for me, changed not called
              If you change something in a created class, restart Pythonista

              1 Reply Last reply Reply Quote 0
              • yaley
                yaley last edited by yaley

                @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
                
                cvp 3 Replies Last reply Reply Quote 0
                • cvp
                  cvp @yaley last edited by

                  @yaley you should add some print in each method to check if called

                  1 Reply Last reply Reply Quote 0
                  • cvp
                    cvp @yaley last edited by

                    @yaley said

                    keyCode = presses[0].keyCode()

                    Key() missing in changed

                    1 Reply Last reply Reply Quote 0
                    • cvp
                      cvp @yaley last edited by cvp

                      @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

                      1 Reply Last reply Reply Quote 0
                      • yaley
                        yaley last edited by

                        @cvp thanks it solved!!!

                        1 Reply Last reply Reply Quote 0
                        • yaley
                          yaley last edited by yaley

                          @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 set activeKeys[keyCode] = presses[0].keyCode() then it works :)

                          cvp 1 Reply Last reply Reply Quote 0
                          • cvp
                            cvp @yaley last edited by

                            @yaley sorry, perhaps I (or my eyes) become too old, but I don't see the difference

                            1 Reply Last reply Reply Quote 0
                            • yaley
                              yaley last edited by

                              @cvp no it’s my wrong again xD They’re absolutely no difference before, lol

                              1 Reply Last reply Reply Quote 0
                              • yaley
                                yaley last edited by

                                @cvp I’ve already changed it, read it again :D The difference is [0].key().keyCode() and [0].keyCode()

                                cvp 1 Reply Last reply Reply Quote 0
                                • yaley
                                  yaley last edited by

                                  Wait, um, after i added print() the pressesChange is not activating

                                  1 Reply Last reply Reply Quote 0
                                  • cvp
                                    cvp @yaley last edited by cvp

                                    @yaley ok. And did you trace, sure that changed def is called?

                                    Sorry: was typing while your previous post was coming

                                    1 Reply Last reply Reply Quote 0
                                    • yaley
                                      yaley last edited by

                                      @cvp i dont think that that def was called :(

                                      cvp 1 Reply Last reply Reply Quote 0
                                      • cvp
                                        cvp @yaley last edited by

                                        @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?

                                        1 Reply Last reply Reply Quote 0
                                        • yaley
                                          yaley last edited by

                                          Yep! Maybe…. No need!

                                          1 Reply Last reply Reply Quote 0
                                          • yaley
                                            yaley last edited by yaley

                                            @cvp But the main problem is just when arrow keys will happen, just like umm i give you an example:
                                            I am detecting keys with ui.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.

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Powered by NodeBB Forums | Contributors