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.


    Keyboard switch.

    Pythonista
    5
    116
    46742
    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.
    • shinya.ta
      shinya.ta @cvp last edited by

      @cvp

      If so, please.

      cvp 1 Reply Last reply Reply Quote 0
      • JonB
        JonB @shinya.ta last edited by

        @cvp I haven't really delved into keyboard extensions on iOS, but apparently you should have access to a textDocumentProxy

        - (void)moveCursorToLeft {
            [self.textDocumentProxy adjustTextPositionByCharacterOffset:-1];
        }
        
        - (void)moveCursorToRight {
            [self.textDocumentProxy adjustTextPositionByCharacterOffset:1];
        }
        
        cvp 1 Reply Last reply Reply Quote 0
        • cvp
          cvp @JonB last edited by cvp

          @JonB Not sure that could help because this proxy is a property of the UIControllerInputView and the associated methods are these ones that the keyboard module offers: move_cursor , insert, ....

          I can move -1,+1 and I hoped that get_context would return the text before and after so i could move of their length but the returned tuple is only texts in the current line

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

            Even this does not work, it stops after one line

              def b_bottom_action(sender):
                while True:
                  t = keyboard.get_input_context()
                  if len(t[0]) == 0:
                    break 
                  keyboard.move_cursor(-len(t[0]))
            
            1 Reply Last reply Reply Quote 0
            • cvp
              cvp @shinya.ta last edited by cvp

              @shinya.ta New version here with buttons for

              • left one position
              • right one position
              • begin of line
              • end of line

              Sorry, not yet found a way to go top and bottom of text

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

                @cvp I could see that might not work., Without maybe a thread to keep moving?

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

                  @JonB Thanks to try to help us (him? 😀). I don't understand how I could follow your advice.
                  I've tried in the button's action to start a thread running the same loop, but no change

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

                    @JonB But this works, not nice to see the cursor moving so slowly

                    import time
                    import threading
                    class my_thread(threading.Thread):
                      def __init__(self):
                        threading.Thread.__init__(self)
                      def run(self):
                        while True:
                          t = keyboard.get_input_context()
                          if len(t[0]) == 0:
                            break 
                          keyboard.move_cursor(-len(t[0]))
                          time.sleep(0.0001)
                    
                    shinya.ta 1 Reply Last reply Reply Quote 0
                    • JonB
                      JonB last edited by

                      Out of curiosity, what if you move_cursor(-10000) or something quite large... Does it only let you move the length of the context, or will it error if you go more than the textview would allow?

                      cvp 2 Replies Last reply Reply Quote 0
                      • shinya.ta
                        shinya.ta @cvp last edited by

                        @cvp

                        I tested.
                        This is wonderful.
                        If there is an up-and-down button, it is perfect.

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

                          @JonB I had tried very big moves, no error but no movement

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

                            @JonB this morning, weird effect, regardless of where the cursor is, it always descends to the same place, while the move parameter is negative. Perhaps, it is too early for my iPad 😊

                            1 Reply Last reply Reply Quote 0
                            • cvp
                              cvp @shinya.ta last edited by

                              @shinya.ta I'll try, but this evening

                              1 Reply Last reply Reply Quote 0
                              • cvp
                                cvp @shinya.ta last edited by cvp

                                @shinya.ta New version here with 6 buttons:

                                • left, right which seem ok
                                • beginning of document, end of document, up one line, down one line

                                But the process is not so good as hoped...
                                I've problems with keyboard.get_input_context that, sometimes 😢, returns texts of previous line, thus no way to compute length of texts at left and right of cursor because the texts are these ones of another line...

                                Thus, buttons are there, in some cases, it is ok, and in other cases not 😂
                                I agree that is not so pleasant, but try it at least.
                                Thanks

                                shinya.ta 2 Replies Last reply Reply Quote 0
                                • shinya.ta
                                  shinya.ta @cvp last edited by

                                  @cvp

                                  I'll take a test.

                                  Is it possible to make a page with only cursor movement?

                                  https://imgur.com/a/7xrsx15

                                  cvp 1 Reply Last reply Reply Quote 0
                                  • shinya.ta
                                    shinya.ta @cvp last edited by

                                    @cvp

                                    The top and bottom buttons don't move.
                                    It doesn't seem to be good if the lines of the "文末" and "文頭" buttons are different.

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

                                      @shinya-ta Do you know about the built in "track ball" mode of the iOS keyboard? Tap keyboard with two fingers (or maybe long press spacebar, might be different depending on device) then the keyboard becomes a trackball that you can drag around your finger to move cursor.

                                      cvp shinya.ta 2 Replies Last reply Reply Quote 0
                                      • cvp
                                        cvp @JonB last edited by

                                        @JonB Thanks to help me to try another solution 😀 because it is fastidious to develop a keyboard exactly as wanted...

                                        1 Reply Last reply Reply Quote 0
                                        • cvp
                                          cvp @shinya.ta last edited by

                                          @shinya.ta said:

                                          The top and bottom buttons don't move

                                          I told you I get problems with these buttons because the keyboard module does not work exactly as expected.

                                          1 Reply Last reply Reply Quote 0
                                          • cvp
                                            cvp @shinya.ta last edited by

                                            @shinya.ta said:

                                            Is it possible to make a page with only cursor movement?

                                            I'll try tomorrow, I stop for today

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