Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » [BUG] Patch to Switch.cpp to support touch screens
[BUG] Patch to Switch.cpp to support touch screens [message #48636] Thu, 10 August 2017 16:39 Go to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi there,
I am trying to reach out the maintainer of the Switch control to see if it is possible modify the Switch.cpp code in order to support touch screens.

I am porting an application developed with U++ on Windows to a raspberry/raspbian platform with a touch screen; the whole story is here.

With the touch screen, when I tap on a Switch control it does not work e.i. it does not set the relevant case, but stays always with the initial case. I added some logging in the gtkevent.cpp file and in the Switch.cpp file.

This is the sequence of gtk events and Switch methods with a real mouse:
GDK_BUTTON_PRESS
GDK_PROPERTY_NOTIFY
Switch::MouseMove: pushindex: 3 value: 002
Switch::LeftDown: pushindex: 3 value: 002
GDK_EXPOSE
GDK_BUTTON_RELEASE
Switch::LeftUp (before the outer if cycle): pushindex: 3 value: 002
Switch::LeftUp (inside the outer if cycle): pushindex: 3 value: 002
Switch::LeftUp (inside the inner if cycle): pushindex: 3 v: 005 value: 002
Switch::LeftUp: pushindex: -1 value: 005


And this is the sequence with the touch screen:
GDK_BUTTON_PRESS
GDK_PROPERTY_NOTIFY
Switch::MouseMove: pushindex: 3 value: 002
GDK_EXPOSE
Switch::MouseMove: pushindex: 3 value: 002
Switch::LeftDown: pushindex: 3 value: 002
GDK_EXPOSE
GDK_MOTION_NOTIFY
GDK_BUTTON_RELEASE
Switch::MouseMove: pushindex: -1 value: 002
GDK_EXPOSE
Switch::LeftUp (before the outer if cycle): pushindex: -1 value: 002
Switch::LeftUp: pushindex: -1 value: 002


With the real mouse the sequence of the gtk events is:
GDK_BUTTON_PRESS
GDK_PROPERTY_NOTIFY
GDK_EXPOSE
GDK_BUTTON_RELEASE


With the touch screen is:
GDK_BUTTON_PRESS
GDK_PROPERTY_NOTIFY
GDK_EXPOSE
GDK_EXPOSE
GDK_MOTION_NOTIFY
GDK_BUTTON_RELEASE
GDK_EXPOSE


So, with a real mouse the LeftUp method is called immediately after the LeftDown, but with the touch screen ther is a MouseMove method in between. This MouseMove method set pushindex to -1. Now let's go where the variable "value" (the variable containig the value of the selected case) is set: inside the LeftUp method.

This is the relevant code:
	if(pushindex >= 0 && pushindex < cs.GetCount()) {
		RefreshCase(GetIndex());
		const Value& v = cs[pushindex].value;
		if(v != value) {
			value = v;
			UpdateAction();
		}
		RefreshCase(pushindex);
	}


As you can see, the value is set only if pushindex >=0, but the MouseMove method has set it to -1.

Let's see what the MouseMove method does:
	int i = GetIndex(p);
	int a = -1;
	if(keyflags & K_MOUSELEFT)
		a = i;
	if(pushindex != a) {
		RefreshCase(pushindex);
		RefreshCase(a);
		pushindex = a;
	}



Onestly I don't understand what that code actually does; I tried to comment out the whole method and the application crashes, so I modified it as follows:

	int i = GetIndex(p);
//	int a = -1;
	int a = pushindex;
	if(keyflags & K_MOUSELEFT)
		a = i;
	if(pushindex != a) {
		RefreshCase(pushindex);
		RefreshCase(a);
		pushindex = a;
	}


With this modification the Switch control works also with the touch screen and the application does not crash. Of course that code is there for some reason, so I am not comfortable with my modification. I kindly ask to the maintainer of Switch.cpp to see how we can work out things in a way that the touch screen is supported. I am available to carry out the required test.
Thanks,
Gio

[Updated on: Thu, 10 August 2017 16:47] by Moderator

Report message to a moderator

Re: [BUG] Patch to Switch.cpp to support touch screens [message #48640 is a reply to message #48636] Thu, 10 August 2017 17:03 Go to previous message
Klugier is currently offline  Klugier
Messages: 1084
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello,

I created following redmine bug #1784 to track your problem in the better way.

Sincerely,
Klugier


U++ - one framework to rule them all.

[Updated on: Thu, 10 August 2017 17:05]

Report message to a moderator

Previous Topic: X11 middle mouse copy paste in own widget [SOLVED]
Next Topic: Add layouts/ParentCtrl to column list
Goto Forum:
  


Current Time: Sat Nov 09 04:10:11 CET 2024

Total time taken to generate the page: 0.00635 seconds