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 hiding TextView
-
You can use ui.convert_point((0,0),rootview,None) to get the screen position of the top frame. However, this has long been broken. in my uicomponents library, I had a RootView class with a replacement for this function. Quite honestly, never been tested on iPhone, but you might find it useful.
Another thing you might try: use convert_point to get the relative y of your textview relative to the root view. This does work. Then simply move the rootview.frame up by that y value. Should always bring the component in question to the top of the screen. For extra credit, account for the content_offset to keep the current line at the top.
-
@JonB Thanks for the hint!
ui.convert_point((0,0),rootview,None)
works for me. Whatever was wrong with it was either fixed or does not seem to bother me in my context. :-) -
@mikael I don't make any assumptions but the existence of the title row which is usually shown when the view is presented using
View.present()
. Of course, there's no way to offer theButtonItem
when there's no title row, but then again there's no close button either.. -
@marcus67: To be clear, my comment was intended for the case where you e.g. want to publish your app on the App Store, and the title bar and the close button no longer make sense. Or you don't like them for esthetic reasons, and are willing to put up with the swipe to close.
-
@mikael Ok, now I get it. Sorry for being so slow. You're right. I haven't thought about this. I guess I would need to put the button somewhere else since I would definitely still need one until Apple finally decides to let the user dismiss the keyboard on the iPhone, too.
Is the title row actually a feature which would automatically be hidden when the app is run as an appstore app? Or will I still have control over it? -
Disclaimer: I have not published anything to App Store.
You probably have control over it, but what would the close button do? Thus I am guessing that if you publish a stand-alone app and you want the title bar, you use e.g. a NavigationView for it, or roll your own.
-
iirc convert point was broken in some orientations in fullscreen. I had a little tester that showed this behavior. i think i tested this in 2.0.
-
@JonB is this the beg reports that you are referring to? https://forum.omz-software.com/topic/2329/bug-list-for-beta-release-160037/1
-
I just ran comparisons between doing a manual walk up the view hierarchy and using ui.convert_point.
I got the same results regardless of orientation, full screen or not, title bar or not - but all on iPhone 6s Plus.
-
try this
https://github.com/jsbain/uicomponents/blob/master/fixed_convert_and_kbframe.pyOn ipad, the problem is that in fullscreen, using convert_point with None thinks 0,0 is at the physical bottom left corner of the screen. also ui.get_keyboard_frame returns nonsense values. things work normally if converting between two views, just not view to None
it seems my code to fix this issue is not working either though... so somewhere along the line the problem changed.