David Kibble Posted August 15, 2017 Report Share Posted August 15, 2017 Hi Guys. I'm after some advice on where and how to modify the ginput code so that I can catch and if necessary block a mouse (touch) event. The reason for wanting to do this is that for bedroom usage I need to turn off the backlight of a control panel, that's easy - if no use for > some timeout turn off the backlight. So when it comes to turning back on, I can easily capture a touch event, BUT the problem then is the user might have touched a button without being able to see it triggering an action they may not want, so we need to say "If backlight is off, catch touch event and turn backlight back on but do not pass that touch event to any widgets for processing". I can see a few places where I could add that sort of code, such as within the gmouse_lld_linux_event.c (I'm using a Linux board) or within ginput_mouse.c itself. Or is there a better way to tackle this? Many thanks in advance. Dave Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted August 15, 2017 Report Share Posted August 15, 2017 Without thinking too hard about this my first idea is to implement a gwinDetachMouse() which you use to detach the GListener that usually gets attached using gwinAttachMouse() (or gwinAttachListener() in the old days). This will prevent the widgets from receiving mouse/touch events. You can attach it to a dummy listener that will fire up the backlight and then detach itself and attach the old listener again. There might be another / better solution but this sounds quite proper to me. Link to comment Share on other sites More sharing options...
David Kibble Posted August 15, 2017 Author Report Share Posted August 15, 2017 Thanks Joel - you are a star. That sounds much cleaner than hacking the core uGFX code. I'll have a look at what's needed for the gwinDetachMouse(). Dave Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted August 15, 2017 Report Share Posted August 15, 2017 It should be fairly easy as the GWIN module uses the GEVENT module for event handling: bool_t gwinAttachListener(GListener *pl) { return geventAttachSource(pl, GWIDGET_SOURCE, 0); } There is a matching geventDetachSource() function in the GEVENT module. I'm looking at this on my phone and I don't remember all the details but on first glance this really looks quite straightforward. @inmarket might have more details in his memory. Link to comment Share on other sites More sharing options...
inmarket Posted August 15, 2017 Report Share Posted August 15, 2017 Great solution Joel. Yep, that really is the best way to handle it. Link to comment Share on other sites More sharing options...
David Kibble Posted August 16, 2017 Author Report Share Posted August 16, 2017 Thanks Guys. Done and working, just detached the source when screen back light goes off then I use a periodic check on the ginputGetMouseStatus() to detect a touch and re-attach the listener. Did that so that it doesn't matter where on the panel is touched. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now