[SailfishDevel] TextArea | Using EnterKey.onClicked

Nicolas Cisco ncis20 at gmail.com
Thu Feb 12 06:12:21 UTC 2015


I've end up copying the source of TextArea (
/usr/lib/qt5/Sailfish/Silica/TextArea.qml ) and adding a custom signal
called pressed. This signal is fired when the Keys.onPressed for the
TextEdit [0] is fired. This signal send the KeyEvent object, so in order to
stop propagation event.accepted has to be setted to true.

With this approach i've encountered several issues:

1- The enter key isn't recognised as an Qt.Key_Enter, but as Qt.Key_Return,
so if you want to filter the enter key, you'll have to use `event.key ==
Qt.Key_Return`.
2- Although the shift is activated in the virtual keyboard, event.modifiers
is always 0. I was expecting i could do event.modifiers & Qt.ShiftModifier
in order to filter the Enter + Shift.
3- As Pekka Vourela said, only enter key and backspace send events.

[0]
https://github.com/NickCis/sailfishos-message-enter-patch/blob/master/org/nickcis/base/MyTextArea.qml

2015-02-12 0:20 GMT-03:00 Nicolas Cisco <ncis20 at gmail.com>:

> I don't understand to what are you refering by sailing RichText. Can you
> explain it?.
> Thanks!
>
> 2015-02-07 16:55 GMT-03:00 Andrey Kozhevnikov <coderusinbox at gmail.com>:
>
>  If you using RichText enter key not adding newline. So depends on
>> settings you entering <br/> yourself or doing send.
>>
>> 07.02.2015 23:37, Nicolas Cisco пишет:
>>
>> Yes, i tried the text.substr(0, text.length-1). In my first mail, i wrote
>> why doesn't wok:
>> "I though of striping the enterkey by hand in the callback like
>> `textArea.text = textArea.text.slice(0, -1)`, but, the problem is that if
>> you are not in the end of the input this doesn't work." (text.substr(0,
>> text.lenght-1) does bassically the same as text.slice(0, -1) ).
>>
>>  I don't think that multiline support is critical. The problem of
>> changing TextArea to a TextField, is that when writing long texts, altought
>> you are writing only one line, TextArea expands in a multilineal way, which
>> is easier to edit, while TextField mantains the widget size and the text
>> moves.
>>
>>  I remember that Mitakuuluu2 [1] [2] app had a nice conversation input.
>> A widget that expands in a multilineal way with a custom enter action. I
>> had a glance at the code, and i find it very hard to understand (i'm a
>> begginner at qml). I'll try to reuse that code, any help on understand it
>> will be appreciated =).
>>
>>  Thanks!
>>
>>  [1]
>> https://github.com/CODeRUS/mitakuuluu2/blob/master/client/qml/EmojiTextArea.qml
>> [2]
>> https://github.com/CODeRUS/mitakuuluu2/blob/master/client/qml/EmojiTextBase.qml
>>
>> 2015-02-07 4:19 GMT-03:00 Asser Lähdemäki <sailfishmail at denden.pw>:
>>
>>> Hello,
>>>
>>> Did you try text.substr(0, text.lenght-1) to remove the last char?
>>>
>>> Also, if the multiline support is important for your UX, perhaps you
>>> could open a Dialog when the text is clicked, where you could accept the
>>> edits without EnterKey.
>>>
>>> Cheers,
>>> Asser
>>>
>>> ncis20 kirjoitti la helmikuuta 7 08:32:12 2015 GMT+0200:
>>>  > Uhh, that's bad news =(, i'll have to use TextField instead and
>>> forget of having multineal support.
>>> > When i said shift+enter, i wasn't refering to actually touching both
>>> keys at the same time, i was thinking in something like caps lock (like
>>> entering upper cased letters in the virtual keyboard).  When you hit the
>>> shift in the virtual keyboard, it sticks and you can input uppercased
>>> letters without multitouch support. I was wondering if with the enter key
>>> could be done something similar, i.e. normal enter would trigger the action
>>> shift+enter (not actually pressing both keys at the same time, but like
>>> uppercased letters) would input a newline.
>>> >
>>> > Thanks for the fast answer, any further infornation about the topic
>>> will also be thanked =).
>>> >
>>> > El vie feb 6 09:13:35 2015 GMT-0300, Pekka Vuorela escribió:
>>> > > to, 2015-02-05 kello 20:11 -0300, Nicolas Cisco kirjoitti:
>>> > >
>>> > >
>>> > > > I try using the qml Keys api:
>>> > > >
>>> > > >
>>> > > >     TextArea {
>>> > > >        id: textArea
>>> > > >        EnterKey.onClicked: console.log("EnterKey.onClicked")
>>> > > >        Key.onEnterPressed: console.log("Key.onEnterPressed")
>>> > > >
>>> > > >        Key.onPressed: console.log("Key.onPressed")
>>> > > >
>>> > > >     }
>>> > >
>>> > > > But doesn't work, the only signal fired is EnterKey.onClicked.
>>> > > >
>>> > > > In addition, my idea is to allow the user to input enters by using
>>> > > > shift and then the enter key, is there a way in order to achieve
>>> > > > this?.
>>> > >
>>> > > At the moment EnterKey doesn't allow to filter out the click event
>>> and
>>> > > indeed Keys attached property doesn't work on Silica editors. Could
>>> look
>>> > > into both, but not sure if that would be too high priority.
>>> > >
>>> > > First, the virtual keyboard sends key events only on few cases: enter
>>> > > and backspace when no word is active (i.e. underlined). Second, shift
>>> > > modifier is not supported on either. And even if shift would be
>>> passed,
>>> > > that as user interface would require multitouch, which doesn't sound
>>> > > like a good idea.
>>> > >
>>> > >
>>> > >
>>> > > _______________________________________________
>>> > > SailfishOS.org Devel mailing list
>>> > > To unsubscribe, please send a mail to
>>> devel-unsubscribe at lists.sailfishos.org
>>> > >
>>> >
>>> > --
>>> > Enviado desde mi Jolla
>>> > _______________________________________________
>>> > SailfishOS.org Devel mailing list
>>> > To unsubscribe, please send a mail to
>>> devel-unsubscribe at lists.sailfishos.or
>>> _______________________________________________
>>> SailfishOS.org Devel mailing list
>>> To unsubscribe, please send a mail to
>>> devel-unsubscribe at lists.sailfishos.org
>>>
>>
>>
>>
>>  --
>> Nicolas Cisco
>> www.nckweb.com.ar
>>
>>
>> _______________________________________________
>> SailfishOS.org Devel mailing list
>> To unsubscribe, please send a mail to devel-unsubscribe at lists.sailfishos.org
>>
>>
>>
>> _______________________________________________
>> SailfishOS.org Devel mailing list
>> To unsubscribe, please send a mail to
>> devel-unsubscribe at lists.sailfishos.org
>>
>
>
>
> --
> Nicolas Cisco
> www.nckweb.com.ar
>



-- 
Nicolas Cisco
www.nckweb.com.ar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20150212/93d4bd75/attachment-0001.html>


More information about the Devel mailing list