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
    5486
    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.
    • 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
              • yaley
                yaley last edited by yaley

                And, also, can vi.View().get_key_commands() and ui.View().key_command(sender) detect keyup? if can, then i can make

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

                  @cvp can it?

                  cvp 2 Replies Last reply Reply Quote 0
                  • yaley
                    yaley last edited by

                    This post is deleted!
                    1 Reply Last reply Reply Quote 0
                    • cvp
                      cvp @yaley last edited by

                      @yaley sorry, was driving to France for some days, not able to answer

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

                        @yaley said

                        can it?

                        No idea

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

                          There are four methods you can implement:

                          https://developer.apple.com/documentation/uikit/uiresponder/1621134-pressesbegan?language=objc

                          You also have pressesEnded_withEvent_, and pressesChanged_withEvent_. Technically, pressesCancelled_withEvent_, but that's rare.

                          See
                          https://developer.apple.com/documentation/uikit/mac_catalyst/handling_key_presses_made_on_a_physical_keyboard?language=objc

                          You can inspect the modifiers:
                          UIKeyModifierAlphaShift 1<<16
                          A modifier flag that indicates the user pressed the Caps Lock key.
                          UIKeyModifierShift 1<<17
                          A modifier flag that indicates the user pressed the Shift key.
                          UIKeyModifierControl 1<<18
                          A modifier flag that indicates the user pressed the Control key.
                          UIKeyModifierAlternate 1<<19
                          A modifier flag that indicates the user pressed the Option key.
                          UIKeyModifierCommand 1<<20
                          A modifier flag that indicates the user pressed the Command key.
                          UIKeyModifierNumericPad 1<<21
                          A modifier flag that indicates the user pressed a key located on the numeric keypad

                          Also, to check for special characters, you would look at charactersIgnoringModifiers, and check for special strings from https://developer.apple.com/documentation/uikit/uikeycommand/input_strings_for_special_keys?language=objc

                          for example 'UIKeyInputRightArrow'

                          (Convert to str before comparing).

                          Technically, when looking at apple docs, in this case then consts are defined as NSString *, so the way you get the value is

                          ObjCInstance(c_void_p.in_dll(c, 'UIKeyInputRightArrow'))
                          

                          But in this case, the NSString is simply equal to the constant name.

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

                            @JonB so….. what should i change?

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