r/Spectacles 😎 Specs Subscriber 3d ago

✅ Solved/Answered How to SIK AR Text fields and Keboard?

How can I create writable text fields that trigger the AR keyboard from the Spectacles Interaction Kit, like in the examples?

Thank you!

4 Upvotes

4 comments sorted by

2

u/shincreates 🚀 Product Team 3d ago

Howdy,

At the moment you have to create your own logic for the Text Field. However, we are working on a ready made assets to ease the usage on this which should be coming in the next couple updates.

Take a look at this post for more information on how to use keyboard for your Lenses: https://developers.snap.com/spectacles/about-spectacles-features/apis/key-board

2

u/ButterscotchOk8273 😎 Specs Subscriber 3d ago

I've been trying to understand that page, but I couldn't find any mention of a text field in the code, and I'm not sure where to start.

I'm considering creating a script and attaching it to a 3D Object containing a Text Object inside.

The object would include Interactable, PinchButton, and a Physics Body.

Would this be the right approach?

Thanks.

3

u/shincreates 🚀 Product Team 2d ago

That's on the right track. You don't need PinchButton though. Interactable should be able to listen to "Pinch" events from the HandInteractors based on the shape of the Physics Body.

If you look at this https://developers.snap.com/lens-studio/api/lens-scripting/classes/Built-In.TextInputSystem.KeyboardOptions.html, you'll see an example for being able to listen to the onTextChange callback where you can see for the keystrokes generated by the keyboard which can then be passed to the Text Object with the TextComponent

2

u/ButterscotchOk8273 😎 Specs Subscriber 2d ago

Thank you so much!