@shinyformica As you can test with this little script, the keyboard_frame_will/did_change is only called when the keyboard is displayed or dismissed. Thus, if you change of field while the keyboard is already displayed, these functions will not been called and you will not see which field has really the focus.
import ui
from objc_util import *
class my_View(ui.View):
def __init__(self):
self.frame = (0,0,400,600)
tv1 = ui.TextView(name='tv1')
tv1.frame = (10,10,180,300)
tv1.text = ''
for i in range(0,50):
tv1.text = tv1.text + str(i) + '\n'
self.add_subview(tv1)
tv2 = ui.TextView(name='tv2')
tv2.frame = (210,10,180,300)
tv2.text = ''
for i in range(0,50):
tv2.text = tv2.text + str(i) + '\n'
self.add_subview(tv2)
def search_editing(self):
for subv in self.subviews:
if type(subv) is ui.TextView:
subvo = ObjCInstance(subv)
#print(dir(subvo))
#return
if subvo.isFirstResponder():
print(subv.name)
def keyboard_frame_will_change(self, frame):
# Called when the on-screen keyboard appears/disappears
# Note: The frame is in screen coordinates.
print('keyboard_frame_will_change',frame)
self.search_editing()
def keyboard_frame_did_change(self, frame):
# Called when the on-screen keyboard appears/disappears
# Note: The frame is in screen coordinates.
self.search_editing()
pass
print('keyboard_frame_did_change',frame)
v = my_View()
v.present('sheet')