[Android-development] Hide Android selection handles manually
Bernhard B
schluchti at gmail.com
Wed Feb 8 21:37:41 CET 2017
Hi,
i tried a few things today, but unfortunately I couldn't make it work.
I implemented the following static method which should get the cursor
handle:
public static void hideCursorHandle(){
QtActivityDelegate activityDelegate = QtNative.activityDelegate();
try{
Field f = activityDelegate.getClass().getDeclaredField("m_cursorHandle");
f.setAccessible(true);
try{
CursorHandle cursorHandle = (CursorHandle) f.get(activityDelegate);
cursorHandle.hide();
Log.i(TAG, "hide");
} catch(IllegalAccessException e1){
Log.e(TAG, "IllegalAccessException");
}
} catch(NoSuchFieldException e){
Log.e(TAG, "NoSuchFieldException");
}
}
In C++ I call the static method twith the following code snippet:
QtAndroid::runOnAndroidThread([&]{
QAndroidJniObject::callStaticMethod<void>("com/example/example/JavaNatives",
"hideCursorHandle");
});
In the Android log I can see the "hide" log message, but unfortunately
the cursor handle doesn't disappear.
Anyone an idea what I am doing wrong here?
Bernhard
2017-02-07 21:30 GMT+01:00 Bernhard B <schluchti at gmail.com>:
> Hello,
>
> during the Qt 5.8 Beta I stumbled accross a few problems regarding the
> newly introduced selection handles (see https://bugreports.qt.io/
> browse/QTBUG-34867).
>
> Unfortunately those problems still exist in Qt 5.8. As I really would need
> a working text selection I thought about fixing the problems myself. The
> biggest problem at the moment for me is, that the selection handles are not
> disappearing. That means, once a selection handle is popping up, it never
> disappears again.
>
> I think that I can improve the usuability a lot when I manually hide the
> selection handle when there is absolutely no need for it (for example when
> the user is typing). My idea is now, that I use JNI to call a Java function
> from C++ and expose that function to QML so that I can call it when there
> is a need (e.q someone is typing text).
>
> The problem now is, that I don't know how to accomplish that easily. I
> already looked in the code diff (see https://codereview.qt-project.
> org/#/c/142466/) and found the hide() method in the CursorHandle.java
> which looks really promissing, but I am not sure how I can get the
> CursorHandle with JNI.
>
> Maybe someone of you can give me a hint on how to do that.
>
> Thanks for your time,
> Bernhard
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/android-development/attachments/20170208/52620459/attachment.html>
More information about the Android-development
mailing list