Only Basic Buttons work on Touchscreen on Linux

Is there anything special I need to do to use a touchscreen on my Linux compiled app? I have a Window with buttons (with graphics), listboxes, and regular buttons, but the only controls that respond to touch are the regular buttons.

The Bevelbuttons do not fire any events and when I try to select a row in my ListBox the touch is completely ignored. Plug in a mouse and it all works just fine.

Touch screen works perfectly in any other app on the computer.

I’ve built many touch interfaces with Linux/RPi and elements like drop-down menus are terrible - they either react too briefly to make a selection or don’t seem to respond at all.

I typically create a custom view, like this example below. Where I might use a drop-down list I instead use a listbox, and let the user touch-select from the list. Hope this helps.


thanks - my listbox is one of the controls not responding. for the buttons i was going to try a canvas with an image on it and then detect the touch. still not sure about the check boxes in my listbox control though!

One of my main Linux programs uses almost entirely canvases and containers for controls. I had way too many discrepancies with the built-in controls (size consistency, events, theming) so I made my own.

Screenshot 2024-02-27 at 1.48.45 AM

I learned a lot of lessons while doing this and can offer some pointers.

For some reason, I thought redrawing the more complex controls each time the paint event was called would be wasteful so I cached them in pictures that would draw with Graphics.DrawPicture. It wasn’t until I did some testing I found out that it was very inefficient. I now just draw using the built-in graphics methods and dropped the CPU from over 40% to around 18%.

Drawing a simple button is quite easy with FillRoundRectangle for the background and DrawRoundRectangle for the border.

I use containers for the more complex controls like listbox, navbar, and panels.

You can subclass a canvas and put all your code in that, then right-click it and select “Inspector Behavior…”. You can choose properties to be available in the inspector at design time. If you make your properties computed then you can add a call to Refresh inside to automatically redraw the control when you set the properties.