[Android-development] Hide Android selection handles manually

Bernhard B schluchti at gmail.com
Thu Feb 9 20:12:09 CET 2017


Hi,

thanks for your answer! I am not sure about the Qt cursor, but the cursor
handle is definitely natively in Java.

Today I finally found out why it was not working. I called the hide()
function in the "onTextChanged" slot of my Textfield. However, right after
the hide() was called, the CursorHandle implementation (in
CursorHandle.java) made the cursor handle visible again afterwards. My
(totally hacky) solution at the moment is, to start a timer in the
"onTextChanged" slot with a small timeout (10ms). When the timer fires the
hide() function gets called. This prevents the cursor handle from showing
when someone types something.

I am not sure if that approach is bulletproof or even has a negative affect
on the typing performance, but until I come up with something better, I
think I will stick with that.

Bernhard

2017-02-09 5:29 GMT+01:00 Юрий Лунёв <yury at indigosystem.ru>:

> I am almost completely sure that Qt cursor has no connection to Android
> system cursor. I think, it is better to spend time researching how cursor
> is done in Qt sources.
>
> 8 февр. 2017 г., в 23:37, Bernhard B <schluchti at gmail.com> написал(а):
>
> 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?
>
>
> ---
> Юрий Лунёв
>
> skype: darth_bitterman
> тел: +7 (908) 51-10-138 <+7%20908%20511-01-38>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/android-development/attachments/20170209/f4e1fce2/attachment.html>


More information about the Android-development mailing list