[Interest] QML Scene2D No Keyboard Events

Kevron Rees tripzero.kev at gmail.com
Wed Oct 18 19:39:26 CEST 2017


On Tue, Oct 17, 2017 at 3:05 PM Jérôme Godbout <jerome at bodycad.com> wrote:

> Make sure you forward the Keys to the elements that can handle them:
>
> Keys.forwardTo: []
>
> You can take a look at
> http://doc.qt.io/qt-5/qml-qtquick-keys.html#key-handling-priorities
> you probably have something else that is grabbing the key event.
>

This is probably the case.  In the Scene2D, "Entity" is the root object.  I
can't use Keys.forwardTo here because Entity (the root is not an Item.  I'm
guessing Keyboard input is handled differently in Qt3D.

I can put a KeyboardDevice and KeyboardHandler inside of the Entity that
contains Scene2D and that seems to work.  But the entity is capturing
keyboard input and there doesn't appear to be a way to forward it to the
qml Item being drawn inside Scene2D.

Without keyboard input, the Scene2D example is incomplete.


>
> Try to forward from your root Item to the your element if it work and
> start displaying the trace, it mean the Key event is not reaching the Item
> (non Item element? bad parenting? something else is consuming the key
> event?) I don't have run the example but that would be my guess.
>
> [image: bodycad] <https://www.bodycad.com/>
> Jerome Godbout
> Software Developer
> 2035 rue du Haut-Bord, Québec, QC, Canada. G1N 4R7
> <https://maps.google.com/?q=2035+rue+du+Haut-Bord,+Qu%C3%A9bec,+QC,+Canada.+G1N+4R7&entry=gmail&source=g>
> T:  +1 418 527-1388 <(418)%20527-1388>
> E: jerome at bodycad.com
> www.bodycad.com
>
> The contents of this email message and any attachments are intended solely
> for the addressee(s) and may contain confidential and/or privileged
> information and may be legally protected from disclosure. If you are not
> the intended recipient of this message or their agent, or if this message
> has been addressed to you in error, please immediately alert the sender by
> reply email and then delete this message and any attachments. If you are
> not the intended recipient, you are hereby notified that any use,
> dissemination, copying, or storage of this message or its attachments is
> strictly prohibited.
>
> Le contenu de ce message et les pièces jointes sont destinés uniquement
> pour le(s) destinataire(s) et peuvent contenir des informations
> confidentielles et / ou privilégiées qui peuvent être protégées légalement
> contre toute divulgation. Si vous n'êtes pas le destinataire de ce message
> ou son agent, ou si ce message vous a été adressé par erreur, s’il vous
> plaît avertir immédiatement l'expéditeur par courriel de réponse, puis
> supprimer ce message et les pièces jointes. Si vous n'êtes pas le
> destinataire prévu, vous êtes par la présente informé que toute
> utilisation, diffusion, copie, ou stockage de ce message ou de ses pièces
> jointes est strictement interdit.
>
> On Tue, Oct 17, 2017 at 4:45 PM, Kevron Rees <tripzero.kev at gmail.com>
> wrote:
>
>> I'm trying to get keyboard events to my qml item that is being displayed
>> as a texture using Scene2D.  I have simply added Keys.onPressed and
>> MouseArea to LogoControls[2] in the Scene2D example[1].  If I uncomment
>> MouseArea, I can see the mouse click console.log message.  But I never see
>> "key pressed".  Is there an extra step necessary to get Keyboard events to
>> this item?
>>
>> [1] https://doc.qt.io/qt-5/qt3d-scene2d-example.html
>>
>> [2]
>>
>> LogoControls {
>>
>>                 id: logoControls
>>
>>                 width: offscreenTexture.width
>>
>>                 height: offscreenTexture.height
>>
>>                 focus: true
>>
>>
>>                 Keys.onPressed: {
>>
>>                     console.log("key pressed")
>>
>>                 }
>>
>>
>>                 /*MouseArea {
>>
>>                     anchors.fill: parent
>>
>>                     onClicked: {
>>
>>                         console.log("clicked...")
>>
>>                     }
>>
>>                 }*/
>>
>>             }
>>
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20171018/8ae5f109/attachment.html>


More information about the Interest mailing list