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.


    Active scope / state to show / hide specific shortcuts

    Pythonista
    3
    7
    3776
    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.
    • zrzka
      zrzka last edited by

      Hi,

      I'm playing with custom HW keyboard shortcuts. It works perfectly and it's available here. Feels odd to swizzle outside of +load, but it's another story. @omz is there an easy way how to distinguish between different Pythonista states? I mean - editor is visible, editor is active, console is visible, ... I can traverse view hierarchy, view controllers, check their states, ... to find what I need. But I assume there is some nice property in PythonistaWindow, which can tell me in what state Pythonista is? I assume there's something like this, because PythonistaWindow.keyCommands returns different key commands based on current state. Searching, searching, but not luck yet. Basically I would like to solve this.

      Or I can try to switch to addKeyCommand on specific view controllers (should work, didn't test it yet).

      Thanks,
      Zrzka

      Phuket2 1 Reply Last reply Reply Quote 0
      • Phuket2
        Phuket2 @zrzka last edited by

        @zrzka, sorry for some dumb questions here. But firstly I think I learned something new. I have a pythonista_startup.py in my site-packages dir. Sets the font, turns off some animations for showing the keyboard etc. I noticed you said your startup should be placed in the site-packages-3. As a test, created a new startedup file in there, just got it to print to the console. Hmmmm, low and behold both scripts are run. That's nice. One thing that was strange, i can not predict which one runs first.
        Anyway, to the more stupid part of the question. With the HW keyboard hooks you are doing, is it work in progress has far as what you can hook into. And then you will be adding different parts of the the ui you can assign keys to? So at the moment, i see you are using cmd / to toggle commenting.
        Is my assessment correct?

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

          site-packages-3 only because I don't care about Python 2. We've got everything in Python 3 and I'm using Python 3 only on iPad as well.

          What's my motivation / goal for this? I do use iPad for two days a week as a main development machine. I miss shortcuts for close current tab, close other tabs except current one, select next / previous tab, step over, step in, ... I have external keyboard and I want to leverage it as much as possible instead of tapping on display. That's what I want to achieve.

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

            @Phuket2 You can have one pythonista_startup scripts in every site-packages(-2|3) folder, and they follow the same rules as the modules in a site packages folder. The startup script in site-packages-3 is only executed in the Python 3 interpreter, while the script in site-packages is executed in both. There is no defined order in which the interpreters are initialized, it depends on system load etc.

            Phuket2 1 Reply Last reply Reply Quote 0
            • Phuket2
              Phuket2 @omz last edited by

              @omz , ok - thanks. I haven't needed to think about it for so long. But I still have the below entries in my startup file. I love it.
              But it works out good in this case, because i can add @zrzka startup file without affecting my trusty one I have had for so long.

              UIView.beginAnimations_(None)
              UIView.setAnimationDuration_(0)
              
              1 Reply Last reply Reply Quote 0
              • zrzka
                zrzka last edited by

                @Phuket2 yeah, my one works, but it's kinda experimental. Better word is dangerous probably, because of swizzling outside of +load, accessing/modifying implementation details Ole can change any time, ...

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

                  @zrzka I don't have radical UI changes planned at the moment, so it probably won't break for a while.

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