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 » Developing U++ » U++ Developers corner » Touchscreen on raspberry: problem with events
Re: Touchscreen on raspberry: problem with events [message #48635 is a reply to message #48625] Thu, 10 August 2017 16:22 Go to previous messageGo to previous message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Ok, I found the problem and a verrrrrrrrrrrrrrrry nasty solution.

This is the cycle 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 cycle 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 LeftUp method is called immediately after the LeftDown; with the touch screen there is a MouseMove method in between. This MouseMove method set pushindex to -1. Now let's go where the variable "value" (the variable containing 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;
	}



Honestly 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 so comfortable with my modification. I will try to reach out the person who wrote Switch.cpp to see how we can work out things in a way that the touch screen is supported. Thanks a lot Klugier for the support.
Regards,
Gio
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Help wanted for DebugVisualizer
Next Topic: Upp as a shared library
Goto Forum:
  


Current Time: Tue Apr 16 22:52:18 CEST 2024

Total time taken to generate the page: 0.01969 seconds