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.


    Making hotkeys

    Pythonista
    3
    5
    3432
    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.
    • reefboy1
      reefboy1 last edited by

      How did programs like stash make their hot keys?

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

        If you're talking about key combinations on an external Bluetooth keyboard, that is done by following the position of the cursor in the TextField. Cmd+Up/Down are default iOS key combos that move the cursor to the beginning or end of a text area, so StaSh can tell that when the cursor suddenly moves to the top the user has pressed Cmd+Up. Of course you can also manually move the cursor to the beginning and that will have the same effect, there's no way to tell the difference.

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

          How would you be able to make these though? Its kind of like making a new keyboard i guess

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

            Not really. TextField delegates can have a method set that is run automatically every time the cursor moves. That code can check whether the new cursor position is at the start/end of the text field, and if so, run some action (such as going through the command history in StaSh) and then move the cursor back to the old position. The cursor never visibly moves, so to the user it looks like a normal key combination.

            This kind of thing only makes sense for fn/alt/cmd + arrow keys though. Other key presses can also be detected in a similar way, but that would block normal use of the text field. None of the cmd + letter combinations cause any visible changes to the text in the text field, so they can't be detected like this.

            Just to be clear - are you talking about Stash's support for Bluetooth keyboards, or about the additional on-screen keys under the text field (tab, hist, up, down, etc.)? Because those extra keys are just normal UI buttons.

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

              This is simply a ui view that contains a bunch of buttons arranged horizontally. The action of those buttons is to replace the range currently selected in the textview with the text of the key. There are also some special buttons which take other actions.

              Take a look at the stash.py source code, it is pretty clean. Search for vk_tapped, and you can see how the button is initially created, and then what it does in the action.

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