Pythonista special key row problems in IOS 14
-
It appears IpadOS 14 broke the special key row in Pythonista. After editing for a short while the center section of keys disappears. A while later the remaining keys shrink further to the sides. It also appears the cursor positioning by sliding over the key row does not work in the center portion, even when the keys are still showing.
https://share.icloud.com/photos/0IcGyZcOAkshHXxcFR2087a5Q
https://share.icloud.com/photos/02XeIxGZlrfj1JsxYDWYm6YgQ
-
@cvp I learn a lot adapting your scripts to my needs !
You will find after this message my/your script to add a keyboard icon in the titlebar to call my script to add my special key row to the keyboard.
The system is rather practical, but to make the handling as transparent as possible : when I add my key row, I hide the keyboard withtv.endEditing(True)
, and I would like to make it reappear with my special key row : but Iβve not found a command as simple as tv.startEditing π ; itβs perharps possible to simulate a touch in the TextView, but I neither canβt find a solution to do it π₯Ά
After several hours of searching, I throw in the towel and ask for helpβ¦π₯΅from objc_util import * import ui from ui3.sfsymbol import * w = ObjCClass('UIApplication').sharedApplication().keyWindow() main_view = w.rootViewController().view() def get_toolbar(view): # get main editor toolbar, by recursively walking the view sv = view.subviews() for v in sv: if v._get_objc_classname().startswith(b'OMTabViewToolbar'): return v tb = get_toolbar(v) if tb: return tb # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ def keyboard_btn_action(sender): def run_script(scriptPath): import os from objc_util import ObjCInstance,ObjCClass dir = os.path.expanduser(scriptPath) I3=ObjCClass('PYK3Interpreter').sharedInterpreter() I3.runScriptAtPath_argv_resetEnvironment_(dir, [''], True) iCloudPath = "/private/var/mobile/Library/Mobile Documents/iCloud~com~omz-software~Pythonista3/Documents/" iPadPath = '~/Documents/' scriptPath = 'PROJETS/KEYBOARD/my_special_key_row.py' run_script(iCloudPath + scriptPath) # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ def create_keyboard_button(action,index=0): global __persistent_views assert(callable(action)) tb = get_toolbar(main_view) try: __persistent_views except NameError: __persistent_views={} #check for existing button in this index and delete if needed remove_toolbar_button(index) btn = ui.Button() btn.frame = (110, 24, 40, 40) if ui.get_ui_style() == 'dark': btn.tint_color = 'white' else: btn.tint_color = '#0D89B5' btn.image = SymbolImage('keyboard', point_size=14, weight=THIN, scale=SMALL) btn.image = btn.image.with_rendering_mode(ui.RENDERING_MODE_AUTOMATIC) btn.action=action btn_obj=ObjCInstance(btn) __persistent_views[index]=(btn,action) tb.superview().superview().addSubview_(btn_obj) # in front of all buttons return btn # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ def remove_toolbar_button(index): global __persistent_views try: btn,action = __persistent_views.pop(index) btn.action= None ObjCInstance(btn).removeFromSuperview() except KeyError: pass # =================================================================== #if __name__=='__main__': # if imported by pythonista startup create_keyboard_button(keyboard_btn_action) create_keyboard_button(keyboard_btn_action)
-
@Enez-Houad try
def keyboard_btn_action(sender): def run_script(scriptPath): import os from objc_util import ObjCInstance,ObjCClass dir = os.path.expanduser(scriptPath) I3=ObjCClass('PYK3Interpreter').sharedInterpreter() I3.runScriptAtPath_argv_resetEnvironment_(dir, [''], True) iCloudPath = "/private/var/mobile/Library/Mobile Documents/iCloud~com~omz-software~Pythonista3/Documents/" iPadPath = '~/Documents/' scriptPath = 'PROJETS/KEYBOARD/my_special_key_row.py' run_script(iCloudPath + scriptPath) @on_main_thread def disp_kbd(): from editor import _get_editor_tab tab = _get_editor_tab() if tab: tab.editorView().textView().becomeFirstResponder() disp_kbd()
-
@Enez-Houad said:
my/your script to add a keyboard icon in the titlebar
I must admit with humulity that the most complex part of this code comes from @JonB π€«
-
@cvp Thanks a lot ! Iβm happy to see that I progress slowlyβ¦
I had foundtextView().becomeFirstResponder()
but couldnβt find to witch element it had to be applied. The_get_editor_tab
is not documented ! To find it, do you openeditor.py
in thesite-packages
ofStandard Library
?
It's very instructive π€, I'm going to end up managing on my own. π
-
last edited by
-
the problem gets worse, and don't ask me how it happens...
-
I begin to panic
-
With me on iOS 14.3 / iPad it seems to have something to do with the βdarkmodeβ setting. When running in βlightβ mode the problem did not occur yet. When I switch back to dark mode, the extra keyboard row splits again after switching between file tabs in the editor.
so, maybe use light mode for Pythonista?
-
@janplxt said:
iPad it seems to have something to do with the βdarkmodeβ setting.
I don't think so, see my first examples in the topic.