Controlling GUI elements with physical controls

Hello! I’m trying to implement clickwheel-style rotary encoder navigation to a project.
It seems most of the examples are very touchscreen oriented, so I’m just having trouble knowing what to call to control them with a physical controller.

For example, I’ve so far been able to highlight options in a ListBox with the encoder, but I’m unsure of how to actually “confirm” the selection.

Any tips or pointers would be appreciated.

I see two options : either modify the ListBoxItem code to respond to a HardwareButton ‘Select’ event, or catch the encoder button-press event and use that as a signal to read SelectedItem from ListBox and act on that current value. The latter approach is probably the easiest.

I did a quick walk through of the UI lib and I see that some controls only respond to touch and are a bit hard to adapt to hardware buttons. I opened an issue that I suspect will get dealt with in a future sweep through the lib along with some other UI work that is also in the issues list.

In any case, just catch the button press, read Listbox.SelectedItem and act accordingly. That’s the best suggestion I have based on what you’ve shared so far. Hope that helps.

That makes sense, thanks. Still trying to wrap my head around the library, I’m more familiar with QT than WPF.

Also, for the GHI folks–it’d be nice to have a page of screenshots of each GUI control somewhere on the docs to see what they look like. Would help, for example, figuring out the difference between a listbox and a dropdown.

We have a plan to revisit UI after we get 2.1 out very soon.

Also, see this please Improve UI · Issue #742 · ghi-electronics/TinyCLR-Libraries · GitHub

Welcome to the community.

I want to suggest adding borders to controls. For example, a TextBox has no borders and this is not convenient - I had to create an additional Border control and place a TextBox in it.

1 Like

Add to this that static text has no background option either. I have to use edit boxes and set the background and set enable to false.

This will be forgotten if you do not add to GitHub

2 Likes