Forum Archive

Keyboard switch.

shinya.ta

If you use this script to switch the keyboard, the existing keyboard will be hidden.
How can I change the beta version to use with the existing keyboard?

import ui
from objc_util import *
import clipboard
import speech

v = ui.View()
v.frame = (0,0,500,320)
v.name = 'Move cursor in TextView'

tv = ui.TextView()
tv.name = 'TextView'
tv.frame = (0,10,380,250)
tv.font = ('Arial Rounded MT Bold',20)
tv.text = 'aรฉ๐Ÿ˜ข๐Ÿ‡ฏ๐Ÿ‡ต๐Ÿ‘จโ€๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ง'
v.add_subview(tv)

def say_char(tv):
    # test speech character at cursor
    idxtopos = IndexToPos('')       # list index to position
    i = tv.selected_range[0]
    #print(i,idxtopos)  
    i = idxtopos[i]                                 # used to check if same base character
    if i < len(tv.text):
        c = tv.text[i]
        if c == ' ':
            c ='space'
        speech.say(c,'jp-JP')


def selected_range(i):
    tvo = ObjCInstance(tv)
    p1 = tvo.positionFromPosition_offset_(tvo.beginningOfDocument(), i)
    p2 = p1
    tvo.selectedTextRange = tvo.textRangeFromPosition_toPosition_(p1, p2)
    say_char(tv)
    return 

# some emoji like flags count as 2 for len but as 4 for selected_range
def IndexToPos(type):
    tvo = ObjCInstance(tv)
    # build array index -> position in range
    idxtopos = []
    pre_x = -1
    #print(tv.text)
    for c in tv.text:
      # nbr characters used e=1 รฉ=1 ๐Ÿ˜‚=1 ๐Ÿ‡ฏ๐Ÿ‡ต=2 ๐Ÿ‘จโ€๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ง=7
      # some emoji generate more than one character, 
      # sometimes counted for more than one in range
      # 1,2,3->1  4->2
      nb = 1 + int(len(c.encode('utf-8'))/4)
      for j in range(0,nb):
        p1 = tvo.positionFromPosition_offset_(tvo.beginningOfDocument(), len(idxtopos))
        p2 = p1
        rge = tvo.textRangeFromPosition_toPosition_(p1, p2)
        rect = tvo.firstRectForRange_(rge)  # CGRect
        x = rect.origin.x
        if x == float('inf') or x == pre_x:
          # same x as previous one, composed character
          pass
        else:
          pre_x = x
          i = len(idxtopos)
        idxtopos.append(i)                      # start position of c
      #print(c,nb,len(idxtopos)-1,i,x)
    idxtopos.append(i+1)                            # end position of last c
    #print(idxtopos)
    # get index of actual cursor
    i = tv.selected_range[0]                # actual position of cursor
    # often p is one of sub_chars, not always the first one
    p = idxtopos[i]                                 # used to check if same base character
    #print(p,i,idxtopos)
    if type == 'left':
      if i == 0:
        return                                              # already before character
      while True:
        i = i - 1
        if idxtopos[i] != p:
          q = idxtopos[i]
          # seach first sub-character
          while i > 0:
            if idxtopos[i-1] != q:
              break
            i = i - 1
        break
    elif type == 'right':
      if i == (len(idxtopos)-1):
        return                                              # already after last character
      while True:
        i = i + 1
        if idxtopos[i] != p:
          break
    elif type == 'end':
      i = len(idxtopos)-1
    else:
      return idxtopos
    r = idxtopos[i]
    selected_range(i)
    return idxtopos

b_top = ui.Button()
b_top.frame = (285,302,94,41)
b_top.title = 'ๆ–‡้ ญ'
b_top.background_color = 'white'
b_top.border_width = 1
def b_top_action(sender):
    tv = sender.superview['TextView']
    tv.selected_range = (0,0)
b_top.action = b_top_action
v.add_subview(b_top)

b_left = ui.Button()
b_left.frame = (190,262,94,41)
b_left.title = 'โฌ…๏ธŽ'
b_left.background_color = 'white'
b_left.border_width = 1
def b_left_action(sender):
    idxtopos = IndexToPos('left')       # list index to position
b_left.action = b_left_action
v.add_subview(b_left)

b_right = ui.Button()
b_right.frame = (285,262,94,41)
b_right.title = 'โžก๏ธŽ'
b_right.background_color = 'white'
b_right.border_width = 1
def b_right_action(sender):
    idxtopos = IndexToPos('right')      # list index to position
b_right.action = b_right_action
v.add_subview(b_right)

b_bottom = ui.Button()
b_bottom.frame = (190,302,94,41)
b_bottom.title = 'ๆ–‡ๆœซ'
b_bottom.background_color = 'white'
b_bottom.border_width = 1
def b_bottom_action(sender):
    idxtopos = IndexToPos('end')        # list index to position
b_bottom.action = b_bottom_action
v.add_subview(b_bottom)

def get_xy(tv):
    idxtopos = IndexToPos('')       # list index to position
    tvo = ObjCInstance(tv)
    x_y = []
    for i in range(0,len(idxtopos)+1):  # x,y of each character
      p1 = tvo.positionFromPosition_offset_(tvo.beginningOfDocument(), i)
      rge = tvo.textRangeFromPosition_toPosition_(p1,p1)
      rect = tvo.firstRectForRange_(rge)    # CGRect
      x,y = rect.origin.x,rect.origin.y
      if i == len(idxtopos):
        if i > 0:
          x,y = x_y[i-1]
        else:
          # text is empty
          x,y = 0,0
      if x == float('inf'):
        x,y = x_prec+15,y_prec
      x_prec,y_prec = x,y
      x_y.append((x,y))
    return x_y

b_up = ui.Button()
b_up.frame = (0,262,94,41)
b_up.title = 'โฌ†๏ธŽ'
b_up.background_color = 'white'
b_up.border_width = 1
def b_up_action(sender):
    tv = sender.superview['TextView']
    x_y = get_xy(tv)
    c = tv.selected_range[0] 
    xc,yc = x_y[c]
    i = c - 1
    while i >=  0:
      x,y = x_y[i]
      if y < yc:
        # previous row
        if x <= xc:
          selected_range(i)
          return
      i = i - 1
b_up.action = b_up_action
v.add_subview(b_up)

b_down = ui.Button()
b_down.frame = (95,262,94,41)
b_down.title = 'โฌ‡๏ธŽ'
b_down.background_color = 'white'
b_down.border_width = 1
def b_down_action(sender):
    tv = sender.superview['TextView']
    idxtopos = IndexToPos('')       # list index to position
    x_y = get_xy(tv)
    c = tv.selected_range[0] 
    #print(x_y,c)
    xc,yc = x_y[c]
    i = c# - 1          # I don't remember why this "- 1"
    while i < len(idxtopos):
      x,y = x_y[i]
      if y > yc:
        # next row
        if x >= xc:
          selected_range(i)
          return
        else:
          if (i+1) < len(idxtopos):
            if x_y[i+1][1] > y: # i = last character of row under cursor
              selected_range(i)
              return
            else:
              pass  # try next x
          else:
            # last character of last row
            selected_range(i)
            return
      i = i + 1
b_down.action = b_down_action
v.add_subview(b_down)

b_copy = ui.Button()
b_copy.frame = (95,302,94,41)
b_copy.title = 'copy'
b_copy.background_color = 'white'
b_copy.border_width = 1
def b_copy_action(sender):
    tv = sender.superview['TextView']
    clipboard.set(tv.text)
b_copy.action = b_copy_action
v.add_subview(b_copy)

b_clear = ui.Button()
b_clear.frame = (0,302,94,41)
b_clear.title = 'clear'
b_clear.background_color = 'white'
b_clear.border_width = 1
def b_clear_action(sender):
    tv = sender.superview['TextView']
    tv.text = ''
b_clear.action = b_clear_action
v.add_subview(b_clear)

#็ตตๆ–‡ๅญ—ใ‚ฟใ‚นใ‚ฏใƒใƒผ

def typeChar(sender):
    '''finds active textinput, and types the button's title'''
    tf=sender.objc_instance.firstResponder()
    tf.insertText_(sender.title)

def nextSet(sender):
    i_set = sender.i_set + 1
    if i_set == sender.n_sets:
        i_set = 0
    #attach our accessory to the textfield, and textview
    ww = vv_array[i_set]
    tvo = tv.objc_instance
    #print(dir(tvo))
    tvo.setInputAccessoryView_(ObjCInstance(ww))
    tvo.reloadInputViews()

#create normal keys
d = 32
dd = 4
emojis = '๐Ÿ˜Š๐Ÿ˜œ๐Ÿ˜ฑ๐Ÿ’ฆโ˜”๏ธ(็ฌ‘)โ˜€๏ธโ˜๏ธโ˜ƒ๏ธโ„๏ธ๐Ÿ™๐Ÿ”๐Ÿš—๐ŸŒˆโญ๏ธ๐Ÿ˜€๐Ÿ˜ƒ๐Ÿ˜„๐Ÿ˜๐Ÿ˜†๐Ÿ˜…๐Ÿ˜‚๐Ÿคฃโ˜บ๏ธ๐Ÿ˜Š๐Ÿ˜‡๐Ÿ™‚๐Ÿ™ƒ๐Ÿ˜‰๐Ÿ˜Œ๐Ÿ˜๐Ÿฅฐ๐Ÿ˜˜๐Ÿ˜—๐Ÿ˜™๐Ÿ˜š๐Ÿ˜‹๐Ÿ˜›๐Ÿ˜๐Ÿ˜œ๐Ÿคช๐Ÿคจ๐Ÿง๐Ÿค“๐Ÿ˜Ž๐Ÿคฉ๐Ÿฅณ๐Ÿ˜๐Ÿ˜’๐Ÿ˜ž๐Ÿ˜”๐Ÿ˜Ÿ๐Ÿ˜•๐Ÿ™โ˜น๏ธ๐Ÿ˜ฃ๐Ÿ˜–๐Ÿ˜ซ๐Ÿ˜ฉ๐Ÿฅบ๐Ÿ˜ข๐Ÿ˜ญ๐Ÿ˜ค๐Ÿ˜ ๐Ÿ˜ก๐Ÿคฌ๐Ÿคฏ๐Ÿ˜ณ๐Ÿฅต๐Ÿฅถ๐Ÿ˜จ๐Ÿ˜ฐ๐Ÿ˜ฅ๐Ÿ˜“๐Ÿค—๐Ÿค”๐Ÿคญ๐Ÿคซ๐Ÿคฅ๐Ÿ˜ถ๐Ÿ˜๐Ÿ˜‘๐Ÿ˜ฌ๐Ÿ˜ฆ๐Ÿ˜ง๐Ÿ˜ฎ๐Ÿ˜ฒ๐Ÿ˜ด'
n_emojis_in_set = 10
n_sets = 1 + int((len(emojis)-1)/n_emojis_in_set)
vv_array = []
for i_set in range(0,n_sets):
    l = int(len(emojis)/n_sets)
    i = i_set * l
    set_emojis = emojis[i:i+l] + 'โฉ'
    w, h = ui.get_screen_size() 
    vv = ui.View(name='set'+str(i_set))
    vv.background_color = 'lightgray'
    h = 0
    x = dd
    y = dd
    for button_title in set_emojis:
        b = ui.Button(title=button_title)
        if button_title == 'โฉ':
            b_action = nextSet
            b.i_set = i_set
            b.n_sets = n_sets
            b.name = 'nextSet'
        else:
            b_action = typeChar
        b.action=b_action
        b.frame = (x,y,d,d)
        b.font = ('.SFUIText', d)
        if (y+d+dd) > h:
            h = y + d + dd
        vv.add_subview(b)
        x = x + d + dd
        if (x+d+dd) > w:
            x = dd
            y = y + d + dd
    vv.frame = (0,0,w,h)
    vv_array.append(vv)

i_set = 0
nextSet(vv_array[n_sets-1]['nextSet'])  # display 1st setet)

v.present('sheet')
tv.selected_range = (0,0)
tv.begin_editing()
cvp

@shinya.ta Hello, hoping you're ok

Try to comment this line by putting a *#* in front of it

#nextSet(vv_array[n_sets-1]['nextSet'])  # display 1st setet)
shinya.ta

@cvp

Dear.@cvp

nextSet(vv_array[n_sets-1]['nextSet']) # display 1st setet)

I don't know where I insert this.

cvp

@shinya.ta You have only to put a # at the line which is the 4th before the end of your script

shinya.ta

@cvp

I put the #, but there is no change.

The window is displayed instead of the keyboard.

cvp

@shinya.ta Please, could you post here your 10 last lines, thanks

shinya.ta

@cvp

        if (x+d+dd) > w:
            x = dd
            y = y + d + dd
    vv.frame = (0,0,w,h)
    vv_array.append(vv)

i_set = 0
nextSet(vv_array[n_sets-1]['nextSet'])  # display 1st setet)

v.present('sheet')
tv.selected_range = (0,0)
tv.begin_editing()
cvp

@shinya.ta put a # before the line nextSet... as here-after
```
if (x+d+dd) > w:
x = dd
y = y + d + dd
vv.frame = (0,0,w,h)
vv_array.append(vv)

i_set = 0

nextSet(vv_array[n_sets-1]['nextSet']) # display 1st setet)

v.present('sheet')
tv.selected_range = (0,0)
tv.begin_editing()```

shinya.ta

@cvp

vv.frame = (0,0,w,h)...

There is an error here.

cvp

@shinya.ta Sorry but without the code, no help possible

cvp

Please post your new 10 last lines

shinya.ta

@cvp

if (x+d+dd) > w:
            x = dd
            y = y + d + dd
    vv.frame = (0,0,w,h)
    vv_array.append(vv)

i_set = 0
#nextSet(vv_array[n_sets-1]['nextSet'])  # display 1st setet)

v.present('sheet')
tv.selected_range = (0,0)
tv.begin_editing()```


    if (y+d+dd) > h:
        h = y + d + dd
    vv.add_subview(b)
    x = x + d + dd
    if (x+d+dd) > w:
        x = dd
        y = y + d + dd
vv.frame = (0,0,w,h)
vv_array.append(vv)

i_set = 0
nextSet(vv_array[n_sets-1]['nextSet']) # display 1st setet)

v.present('sheet')
tv.selected_range = (0,0)
tv.begin_editing()

Insert Code Here
shinya.ta

@cvp

The "indentation error" will appear.

Olaf

The error results from your lines not being well-aligned
Unindenting the x=... and y=... lines should fix it

shinya.ta

@cvp

I'm sorry. The second code is wrong.

shinya.ta

@Olaf

I'm a beginner, so I don't know which line I should go.

cvp

@shinya.ta your modified code is here

shinya.ta

@cvp

I can't use the existing keyboard because it is hidden.
There is no change between the beginning and the change.

cvp

@shinya.ta It's sure that there is a modification between beginning and this last script...
The 4th one before end of script is commented to use the standard keyboard

Or I don't understand your request, in this case, sorry

shinya.ta

@cvp

Can I use this script only in the frame of the keyboard?
Do I need to change my size?

cvp

@shinya.ta Sorry, I don't understand what you want to do. In your initial post, you asked to use standard keyboard instead of the customized one with emojis. Thus, the solution was to not use setInputAccessoryView, thus to comment the line that does this process...

Or, I really don't understand anything.

shinya.ta

@cvp

I'd like to try it once.
How can I do so that I don't use setInputAccessoryView?

cvp

@shinya.ta download the script here and retry

shinya.ta

@cvp

Is the iPad displayed properly?

On iPhone, the text view is displayed on the keyboard, and you can't use the keyboard.

cvp

@shinya.ta you say that textview is displayed on the keyboard, is it not under the keyboard?

shinya.ta

@cvp

The text view is piled up on the keyboard.

cvp

@shinya.ta Never seen that, could you post a "print screen"?

shinya.ta

@cvp

I don't know how to make a posting on the printing screen.

cvp

@shinya.ta explained (to you) here

shinya.ta

@cvp

I tried it before.

But.The "Module Not Found Error" is on the first line and can't be used.

cvp

@shinya.ta That's because you didn't install pyimgur...

shinya.ta

@cvp

Please tell me how to install "pyimgur".

cvp

@shinya.ta

Download this

and this

cvp

Then
- go to your site-packages folder
- create pyimgur folder
- move the two modules that you have just downloaded in this folder
- remove Pythonista from active apps
- back in Pythonista

shinya.ta

@cvp

It is difficult for me, so it takes time.
It takes time to understand.
Just a moment, please.

cvp

@shinya.ta Perhaps, it could be easier for you to upload a photo to Imgur.com without any script.

Go to to https://imgur.com/upload
Tap browse
Tap 2nd line (in French "Phototheque")
Select your photo
Tap ok
Your photo will upload and be displayed
At right, tap download post
Safari will open a new tab
Copy its url
Post this url in the forum

Hoping, I didn't do too much mistakes ๐Ÿ˜€

shinya.ta

@cvp

https://m.imgur.com/a/MynxDlJ

Is this okay?

cvp

@shinya.ta yes

cvp

@shinya.ta I've never seen that

cvp

@shinya.ta I think I understand your problem, wait a minute.

Are you still with the beta version of Pythonista?
When it has expired, did you reinstall the standard version?
What shows settings/Gรฉnรฉral/keyboards?

shinya.ta

@cvp

I've been using the beta version since I was taught the beta version.
We haven't reinstalled the standard version.

The current condition is like this.

https://imgur.com/a/8h7fQww

cvp

@shinya.ta Ok. First, I'm happy (and you too, I hope) that you can now post images in the forum.

If you are in Beta, I don't understand.
As I can see, only the globe is visible, what happens if you tap it.

shinya.ta

@cvp

A beta version of the update was released just now, so if you install it, there will be something wrong.

It becomes like this for a moment.

https://imgur.com/a/rXdCKjp

After that, it becomes like this screen.

https://imgur.com/a/YmDmcMU

cvp

@shinya.ta I didn't know there was a new update of the beta.
As this update modifies something about keyboard, perhaps the problem comes from there

cvp

@shinya.ta you could reinstall previous version:

TestFlight
Previous builds
Display builds
330014 Install

shinya.ta

@cvp

I reinstalled it.
But this is the screen again.
https://imgur.com/a/8oj9pxK

cvp

@shinya.ta said:

I reinstalled it.

Did you reinstall the same build or did you choose the previous build?

cvp

@shinya.ta I understand your problem.

You have added "Move cursor in TextView" as a Pythonista keyboard but this script can't be run as a keyboard, it does not import the keyboard module.
You have made a mix between this script written in the past and the "Japanese Braille keyboard" that I wrote for you.

Remove this script from your keyboard scripts.

cvp

I delete the topic "problem with build 330015"

shinya.ta

@cvp

I've returned it to the previous version.
What should I do to execute this as a keyboard?

cvp

@shinya.ta Not so easy, I'll try....

But, don't forget, this script is written for a TextView in Pythonista and you want to use it anywhere in other apps, like your mail...
It is not at all the same process.
That will not be solved in a few time ๐Ÿ˜ข

cvp

@shinya.ta I've an important question.

This script runs in Pythonista and presents an UI View with a TextView and some buttons,
AND the keyboard has an additional row with emoji"s.

If you want to use something like that in other apps, like Mail, is it only to have this additional row of emoji's?

cvp

What is easy is a little script that you can add to Pythonista keyboards and this new keyboard will offer the English keyboard and a row where you can display and tap your emojis like the actual script.

You can find an initial version here, tell me if it is ok
Of course, you have to add it to Pythonista keyboards via
tools/shortcuts/Pythonista keyboard/+ where you have to choose the script and the title

See here, used in the mail program. But you don't have any TextView because the input field belongs to the Mail app. And, if you want an English keyboard, there is no room for other buttons.

shinya.ta

@cvp

There is no particular need for Emoji.
The most important one is the cursor move button.

cvp

@shinya.ta ๐Ÿ˜ข๐Ÿ˜ข๐Ÿ˜ข๐Ÿ˜ข๐Ÿ˜ข๐Ÿ˜ข๐Ÿ˜ข
Ok, I'll do it.
In summary:
- Pythonista Keyboard usable in all apps
- standard English keyboard
+ left or right cursor

You would not have all cursor move possibilities, I think, because the text field of any app is not a Pythonista TextView or TextField

Agree?

Do you still need emojis or do I put these left/right cursors in the same row?
Please, confirm
Thanks

If ok, it will be for tomorrow, I hope

shinya.ta

@cvp

If there is a space to put, I would like to have Emoji, but I don't mind if it isn't.
You need English and Japanese for the standard language keyboard.

cvp

@shinya.ta The Pythonista keyboard only offers English keyboard.
Of course, you can always tap the globe key to shift to another international keyboard

shinya.ta

@cvp

If so, please.

JonB

@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

@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

cvp

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]))
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

JonB

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

cvp

@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

cvp

@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)
JonB

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?

shinya.ta

@cvp

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

cvp

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

cvp

@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 ๐Ÿ˜Š

cvp

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

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

@cvp

I'll take a test.

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

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

shinya.ta

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

JonB

@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

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

cvp

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

cvp

@shinya.ta said:

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

I'll try tomorrow, I stop for today

shinya.ta

@JonB

I know that function, but it is very difficult to use.
I would like to use the combination with the braille application I had made first for my wife who is totally blind.
If I can do that, I can become happy with all my wife and I who are totally blind.

cvp

@shinya.ta New version here

But, only to be sure that the layout is what you want. Could you check and try, please.

I didn't understand the new key at bottom right of your picture, where I temporary put "???".

Don't hope the keys do what you want, I've a lot of problems with the keyboard module.

โฌ…๏ธ = left one character
โžก๏ธ = right one character
ๆ–‡้ ญ = begin of sentence
ๆ–‡ๆœซ = end of sentence
โฌ†๏ธ = up one line, but it is not entirely ok
โฌ‡๏ธ = down one line, but is not entirely ok
??? = no action, and is entirely ok ๐Ÿ˜‚

I've let emoji's line, tell me if you don't want it.

If no news, have a good week-end.

PS For my curiosity, does your wife still use my (big) program for the Japanese Braille keyboard?

shinya.ta

@cvp

"๏ผŸ๏ผŸ๏ผŸ" is delete button.
It means delete in Japanese.
This is also fine with Emoji.
Everything is perfect.

If possible, I want a copy button.

My wife also uses the braille application.
I use a braille application for a simple document and use an existing keyboard for using a difficult kanji.
Therefore, this keyboard application is necessary for long sentences.

cvp

@shinya.ta Could you
1) post the Japanese characters for delete, is that ๅทฆๅ‰Š้™ค
2) confirm if you want left delete (backspace) or delete at cursor
3) about copy, where do you want the button, it's text
4) what is copy for you? Normally, copy is copy selected text to clipboard

cvp

This is a new version With
1) delete left with the same text as in Braille keyboard app
2) copy button with copy to clipboard of selected text

Please confirm all and position of copy button

shinya.ta

@cvp

The copy button doesn't work well.
I want to copy the text by one push just like a previous copy button.

shinya.ta

@cvp

When you press "โฉ", the following screen will be displayed.

https://m.imgur.com/a/blEMXt9

shinya.ta

@cvp

Can you tell me how to get a new Pythonisa beta version?

My wife uses it in the Pythonisa beta version of my iPhone.
I would like to put a beta version on my wife's iPhone.

cvp

@shinya.ta said:

Can you tell me how to get a new Pythonisa beta version?

See https://testflight.apple.com/join/qDkBu2ur
but don't forget we met a problem with the last build 330015. I'm not sure that customized keyboards like Japanese Braille or this one still works in this build. I have reinstalled the build 330014.

TestFlight
Previous builds
Display builds
330014 Install

cvp

@shinya.ta said:

When you press "โฉ", the following screen will be displayed.

You are right, next version will correct it

cvp

@shinya.ta said:

The copy button doesn't work well.

As described in the keyboard module doc, to copy to clipboard, you have to
authorize full access in
Settings/Pythonista3/Keyboards/Authorize Full Access

cvp

@shinya.ta New version

shinya.ta

@cvp

I had a full access, but the copy button is invalid.
I can't paste it.

cvp

@shinya.ta Very strange. For me, all is ok.
Sure you had already "full access" before or you have just set it on?
If just set, please remove (NOT UNINSTALL) Pythonista from active apps and restart it.
Sure you select something in the text, try first with normal copy in popup menu of select.
Then, select something else and copy via our keyboard

shinya.ta

@cvp

You can't use it on email software or LINE that you often use.
I was able to use it in the text view of the previous cursor moving application.

cvp

@shinya.ta Are you sure that you have installed the last version?
If yes, the โฉ key should work fine.
If it does not work, then you should have forgotten to install the last version.

If yes, I want to be sure that that you hope that the "copy" button copies TO the clipboard, and does not perform a paste FROM the clipboard.

cvp

@shinya.ta said:

I was able to use it in the text view of the previous cursor moving application.

The previous cursor moving application was a "full Pythonista" application and did not need this setting "full access" but this is a keyboard application and needs to be authorized to copy some selected text (from Email by example) to the Clopboard.

I'm not sure but it is possible that, if you modify a setting, you need to restart (NOT REINSTALL) Pythonista, that will say remove it from the active apps and recall it.
Did you do that?

new version with check full access
this is the same version but the title of the copy button will be "no full" if Pythonista setting "full access" is off

shinya.ta

@cvp

I restarted.
But it wasn't good.
It was the same as the previous cursor moving application, and it was the same as when I was using the Japanese voice. It was normal on my wife's iPhone.
But it wasn't good on my iPhone.
It is certain that it is slightly different depending on the device.

cvp

@shinya.ta I hope you have installed the new version.
And do you see the text "copy" or "no full"?

shinya.ta

@cvp

Is the new version "330015"?

cvp

@shinya.ta I speak of the new version of the Pythonista script...Emojis keyboard

And stay in 330014

cvp

@shinya.ta could you test this little script as keyboard and tell me if you
get "qwerty" if tap on "copy" and the tap paste key

import keyboard
import clipboard
import ui
v = ui.View()
b = ui.Button()
b.frame = (2,2,60,32)
b.title = 'copy'
def b_action(sender):
    t = 'qwerty'
    clipboard.set(t)
b.action = b_action
v.add_subview(b)
keyboard.set_view(v, 'expanded')
shinya.ta

@cvp

https://imgur.com/a/4vf330P

I did a test. There is an error.

cvp

@shinya.ta Check your script, you forgot the first line "import keyboard" ๐Ÿ˜ข

shinya.ta

@cvp

I'm sorry.
I was wrong. I was able to paste it.

https://imgur.com/a/6XBKWuG

cvp

@shinya.ta Then the problem you have is not due to the device.
I think you did something wrong.
Please,

1) set setting/Pythonista/keyboards/authorize full access to OFF
2) close the keyboard app

3) choose Emojis Keyboard

The script should show the copy button with "no full" as title

Tell me

Be careful, sometimes we need to close a keyboard, choose another one, close it and re-choose the tested one...
A keyboard seems to stay a little bit too long in memory

shinya.ta

@cvp

I'm sorry.
I don't understand the meaning of the Emoji keyboard.

cvp

@shinya.ta ok, sorry, that's the name I gave to this keyboard...

cvp

@shinya.ta Forget the last check that I have asked. If the little script for copy "QWERTY" works fine, that will say that the setting "full access" is ON thus my last request is useless.
Sorry.

Thus, the only reason I still see for the problem of copy is that you could have not installed the last version of my script. here

shinya.ta

@cvp

I installed the last version, but the result doesn't change.
I don't know why.

cvp

@shinya.ta

Could you install this little script as keyboard.
Then , you select a text where you want, tap the "copy" button and paste the clipboard to check if the action does work.

When you have tested the little script two days ago, it worked with "qwerty", now we check if it works with selected text, just to be sure that the get_selected_text works.

import keyboard
import clipboard
import ui
v = ui.View()
b = ui.Button()
b.frame = (2,2,60,32)
b.title = 'copy'
def b_action(sender):
    t = keyboard.get_selected_text()
    clipboard.set(t)
b.action = b_action
v.add_subview(b)
keyboard.set_view(v, 'expanded')
cvp

@shinya.ta I have exactly the same problem.
If I use my little keyboard script in Mail, it is not ok, it if I use it in Pythonista editor, it works.

It is like if Clipboard of Pythonista keyboard is not the same as another app's keyboard.
I don't know

I've created an issue in the bugs list of a Pythonista, hoping @omz would process it.

shinya.ta

@cvp

I tried it too, but it wasn't good.

cvp

@shinya.ta I'm sorry for you but I don't know if it is a problem of Pythonista or of iOS...
But sure, it is not your iDevice ๐Ÿ˜€

I hope that you could, despite that, use this script for other tasks than copy...
If you need more keys, don't hesitate to ask

cvp

@shinya.ta After some tests, it seems that in my little script and the big script, the "copy" button work in Safari, in Notes, in Pythonista, in Numbers but not in Mail....
This is perhaps an Apple limitation.

shinya.ta

@cvp

Thank you very much. Even if I can't use the copy button, I'm happy that I can move the cursor.
Now my wife can write email happily using both the Braille application and the braille.

Thank you very much.
Thank you very much.

cvp

@shinya.ta for info, Apple doc of customized keyboards says
Because a custom keyboard can draw only within the primary view of its UIInputViewController object, it cannot select text. Text selection is under the control of the app that is using the keyboard. If that app provides an editing menu interface (such as for Cut, Copy, and Paste), the keyboard has no access to it

The standard keyboard of Mail offers a copy button

shinya.ta

@cvp

Thank you for your detailed information.

mukulb

Thanks all for your responses. i was having similar questions and your answers were helpful to me.