2019-08-14 08:26 AM
For projects with a small display, I would like to control display using external navigation buttons or an encoder.
Is it possible to connect the encoder and move the focus between the buttons an then click on it?
Solved! Go to Solution.
2019-08-15 11:35 AM
Hi @ABELA,
It's not you. There's no concept of "focus" in touchgfx / touch sensitive applications. You won't find anything. What i meant was that you need to implement a "focus" state for a custom button. You have the source code for Button, so you can check out the code and get some inspiration. You can also simply draw a "focus" rectangle or something similar around the current Drawable being focused by your external events.
You can cycle through Drawables in your application. When you add() Drawables to your root container in a screen/view (by calling add(myButton); ) you build up a linked list.
You can get a pointer to the first element in this list by calling:
getRootContainer().getFirstChild()
And then maybe;
getRootContainer().getFirstChild()->getNextSibling()
And then you can get its type
getRootContainer().getFirstChild()->getNextSibling()->getType()
.. and compare that against its DrawableType (defined in Drawable.hpp) if that's interesting:
typedef enum
{
TYPE_DRAWABLE,
TYPE_WIDGET,
TYPE_ABSTRACTBUTTON,
TYPE_ANIMATEDIMAGE,
TYPE_BOX,
TYPE_BUTTON,
TYPE_BUTTONWITHICON,
TYPE_BUTTONWITHLABEL,
TYPE_IMAGE,
TYPE_TILEDIMAGE,
TYPE_KEYBOARD,
TYPE_SCALABLEIMAGE,
TYPE_SNAPSHOTWIDGET,
TYPE_TEXTAREA,
TYPE_TEXTAREAWITHONEWILDCARD,
TYPE_TEXTAREAWITHTWOWILDCARDS,
TYPE_TOGGLEBUTTON,
TYPE_TOUCHAREA,
TYPE_CONTAINER,
TYPE_LISTLAYOUT,
TYPE_SCROLLABLECONTAINER,
TYPE_ZOOMANIMATIONIMAGE,
TYPE_RADIOBUTTON,
TYPE_TEXTUREMAPPER,
TYPE_SLIDER,
TYPE_CUSTOMTYPESBEGIN,
TYPE_CLICKABLECONTAINER
} DrawableType;
Hope that can get you started.
/Martin
/Martin
2019-08-14 02:49 PM
Hi @ABELA,
Sure! Read one of the stickies about hardware integration. Once you receive a signal from your external buttons you can then proceed to send events into your application to do whatever you want. You'd have to manually code the gui logic to move focus and issue a button touch. It's totally viable. Let me know if you need some help.
/Martin
2019-08-15 09:58 AM
We did not find focus properties on widgets. Probably badly searched. 8)
Can you bring some more explanation.
My idea is that I have three events from encoder - a "step to the left", a "step to the right", and "select". How can I get a list of all widgets of the current view and when I receive an event to "the left" or "the right" to move the focus while waiting for an event "select" to be pressed?
How can I bypass only the elements I need?
Where do widgets have focus property?
Thank you very much.
2019-08-15 11:35 AM
Hi @ABELA,
It's not you. There's no concept of "focus" in touchgfx / touch sensitive applications. You won't find anything. What i meant was that you need to implement a "focus" state for a custom button. You have the source code for Button, so you can check out the code and get some inspiration. You can also simply draw a "focus" rectangle or something similar around the current Drawable being focused by your external events.
You can cycle through Drawables in your application. When you add() Drawables to your root container in a screen/view (by calling add(myButton); ) you build up a linked list.
You can get a pointer to the first element in this list by calling:
getRootContainer().getFirstChild()
And then maybe;
getRootContainer().getFirstChild()->getNextSibling()
And then you can get its type
getRootContainer().getFirstChild()->getNextSibling()->getType()
.. and compare that against its DrawableType (defined in Drawable.hpp) if that's interesting:
typedef enum
{
TYPE_DRAWABLE,
TYPE_WIDGET,
TYPE_ABSTRACTBUTTON,
TYPE_ANIMATEDIMAGE,
TYPE_BOX,
TYPE_BUTTON,
TYPE_BUTTONWITHICON,
TYPE_BUTTONWITHLABEL,
TYPE_IMAGE,
TYPE_TILEDIMAGE,
TYPE_KEYBOARD,
TYPE_SCALABLEIMAGE,
TYPE_SNAPSHOTWIDGET,
TYPE_TEXTAREA,
TYPE_TEXTAREAWITHONEWILDCARD,
TYPE_TEXTAREAWITHTWOWILDCARDS,
TYPE_TOGGLEBUTTON,
TYPE_TOUCHAREA,
TYPE_CONTAINER,
TYPE_LISTLAYOUT,
TYPE_SCROLLABLECONTAINER,
TYPE_ZOOMANIMATIONIMAGE,
TYPE_RADIOBUTTON,
TYPE_TEXTUREMAPPER,
TYPE_SLIDER,
TYPE_CUSTOMTYPESBEGIN,
TYPE_CLICKABLECONTAINER
} DrawableType;
Hope that can get you started.
/Martin
/Martin