U++ framework
Do not panic. Ask here before giving up.

Home » Developing U++ » U++ Developers corner » Using Pen with U++
Re: Using Pen with U++ [message #56595 is a reply to message #56592] Fri, 26 March 2021 18:52 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Yes, default: is great (if you also handle both "case PEN_DOWN:" and "case PEN_UP:") Anyway, this is not important now. I can write case 0: Smile

I agree 100 %: We do not want to add any pen support to client code.

However, e.g. RectTracker does not work as is with my Wacom tablet. The specific pen support (I just posted) is simply required for it to work. (I'm now under impression that RectTracker works with your tablet perfectly without these changes... ?? Perhaps XP-PEN drivers can avoids Windows Ink and work more mouse-like through the stack.)

Best regards,

Tom
Re: Using Pen with U++ [message #56597 is a reply to message #56595] Sat, 27 March 2021 09:11 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Tom1 wrote on Fri, 26 March 2021 18:52

However, e.g. RectTracker does not work as is with my Wacom tablet. The specific pen support (I just posted) is simply required for it to work. (I'm now under impression that RectTracker works with your tablet perfectly without these changes... ?? Perhaps XP-PEN drivers can avoids Windows Ink and work more mouse-like through the stack.)


Sorry, I might get lost in the code that we exchange here a lot...

Do you mean that my variant where Pen returns false and RectTracker is called in normal LeftDown does not work with Wacom? (My impression so far was that you are only testing RectTracker in Pen virtual method).

If so, does it mean RectTracker does not work even in pre-Pen U++? (With Wacom in "mouse mode")

Mirek

[Updated on: Sat, 27 March 2021 09:12]

Report message to a moderator

Re: Using Pen with U++ [message #56600 is a reply to message #56597] Sat, 27 March 2021 12:20 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
mirek wrote on Sat, 27 March 2021 10:11
Tom1 wrote on Fri, 26 March 2021 18:52

However, e.g. RectTracker does not work as is with my Wacom tablet. The specific pen support (I just posted) is simply required for it to work. (I'm now under impression that RectTracker works with your tablet perfectly without these changes... ?? Perhaps XP-PEN drivers can avoids Windows Ink and work more mouse-like through the stack.)


Sorry, I might get lost in the code that we exchange here a lot...

Do you mean that my variant where Pen returns false and RectTracker is called in normal LeftDown does not work with Wacom? (My impression so far was that you are only testing RectTracker in Pen virtual method).

If so, does it mean RectTracker does not work even in pre-Pen U++? (With Wacom in "mouse mode")

Mirek


Hi,

With original pre-Pen U++, RectTracker worked with Wacom at correct coordinates. (It only suffered from the Windows Ink induced 2 cm starting delay, but the rectangle followed pen thereafter.)

With current trunk code and testing with:
bool Pen(Point p, const PenInfo& pn, dword keyflags) override {
		if(keyflags & K_SHIFT)
			return false;
		if(pn.pressure) {
			if((!!pn.pressure == !!pen.pressure) && drawing.GetCount())
				drawing.Top().Add(MakeTuple(pn.pressure, p));
			else
				drawing.Add().Add(MakeTuple(pn.pressure, p));
		}
		pen = pn;
		Refresh();
		return true;
	}
	
	void LeftDown(Point p, dword keyflags) override {
		if(keyflags & K_SHIFT) {
			RectTracker tracker(*this);
			tracker.MinSize(Size(-100000,-100000));
			tracker.Track(Rect(p,p));
		}
	}

the tracking rect still of course has the 2 cm starting delay. However, now the rect dragged corner lags behind with a 2 cm constant dx,dy offset. Please see below a photo of a live 'while dragging' situation. So, actually, RectTracker is now worse than before introducing pen support:
index.php?t=getfile&id=6406&private=0

Further on, what I really need with RectTracker, is that there is no 2 cm reaction delay. The tracking must start immediately from PEN_DOWN event. My RectTracker inherited sketching code requires immediate reaction for even a single pixel pen drags. This is why I need specific Pen() support in RectTracker.

Best regards,

Tom
Re: Using Pen with U++ [message #56604 is a reply to message #56600] Sat, 27 March 2021 20:23 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Tom1 wrote on Sat, 27 March 2021 12:20
mirek wrote on Sat, 27 March 2021 10:11
Tom1 wrote on Fri, 26 March 2021 18:52

However, e.g. RectTracker does not work as is with my Wacom tablet. The specific pen support (I just posted) is simply required for it to work. (I'm now under impression that RectTracker works with your tablet perfectly without these changes... ?? Perhaps XP-PEN drivers can avoids Windows Ink and work more mouse-like through the stack.)


Sorry, I might get lost in the code that we exchange here a lot...

Do you mean that my variant where Pen returns false and RectTracker is called in normal LeftDown does not work with Wacom? (My impression so far was that you are only testing RectTracker in Pen virtual method).

If so, does it mean RectTracker does not work even in pre-Pen U++? (With Wacom in "mouse mode")

Mirek


Hi,

With original pre-Pen U++, RectTracker worked with Wacom at correct coordinates. (It only suffered from the Windows Ink induced 2 cm starting delay, but the rectangle followed pen thereafter.)

With current trunk code and testing with:
bool Pen(Point p, const PenInfo& pn, dword keyflags) override {
		if(keyflags & K_SHIFT)
			return false;
		if(pn.pressure) {
			if((!!pn.pressure == !!pen.pressure) && drawing.GetCount())
				drawing.Top().Add(MakeTuple(pn.pressure, p));
			else
				drawing.Add().Add(MakeTuple(pn.pressure, p));
		}
		pen = pn;
		Refresh();
		return true;
	}
	
	void LeftDown(Point p, dword keyflags) override {
		if(keyflags & K_SHIFT) {
			RectTracker tracker(*this);
			tracker.MinSize(Size(-100000,-100000));
			tracker.Track(Rect(p,p));
		}
	}

the tracking rect still of course has the 2 cm starting delay. However, now the rect dragged corner lags behind with a 2 cm constant dx,dy offset. Please see below a photo of a live 'while dragging' situation. So, actually, RectTracker is now worse than before introducing pen support:
index.php?t=getfile&id=6406&private=0

Further on, what I really need with RectTracker, is that there is no 2 cm reaction delay. The tracking must start immediately from PEN_DOWN event. My RectTracker inherited sketching code requires immediate reaction for even a single pixel pen drags. This is why I need specific Pen() support in RectTracker.

Best regards,

Tom


OK, this works just fine with xp-pen...

Widgets in general do work? (Because if it is this way, I would just expect the offset to be everywhere...)

What happens if you remove return 0L in pen processing?

Mirek
Re: Using Pen with U++ [message #56605 is a reply to message #56604] Sat, 27 March 2021 20:45 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Yes. Widgets mostly work. Some flickering with e.g. Menu, but I think nothing is severely broken. I can do a more thorough check later.

Breaking out from WM_POINTER* instead of return 0L; does not have any effect on this test with RectTracker. Offset remains.

The core problem in my opinion is ::GetCursorPos which does not work with pen. This comes evident with drags.

Best regards,

Tom
Re: Using Pen with U++ [message #56607 is a reply to message #56605] Sun, 28 March 2021 13:15 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Tom1 wrote on Sat, 27 March 2021 20:45
Yes. Widgets mostly work. Some flickering with e.g. Menu, but I think nothing is severely broken. I can do a more thorough check later.

Breaking out from WM_POINTER* instead of return 0L; does not have any effect on this test with RectTracker. Offset remains.

The core problem in my opinion is ::GetCursorPos which does not work with pen. This comes evident with drags.


OK. In the new commit I treat GetCursorPos as "not reliable", overriding it with position got from lParam.

Can you try?
Re: Using Pen with U++ [message #56611 is a reply to message #56607] Sun, 28 March 2021 18:11 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Quote:
OK. In the new commit I treat GetCursorPos as "not reliable", overriding it with position got from lParam.

Hi Mirek,

That was a correct move. Now RectTracker works correctly after 2 cm Windows Ink threshold is crossed. This is via "Pen() return false; to LeftDown()".

In Pen(), RectTracker does not work at all yet.

I also tested with UWord to see how different widgets work. I could not immediately find anything that does not. Only dragging a top menu item to open a drop down menu causes flickering of the selected item on the drop down menu. If the drop down menu is opened by a pen click, hovering on top of the sub menu works correctly without any flickering.

Best regards,

Tom
Re: Using Pen with U++ [message #56612 is a reply to message #56611] Mon, 29 March 2021 11:10 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
[quote title=Tom1 wrote on Sun, 28 March 2021 18:11]Quote:
Only dragging a top menu item to open a drop down menu causes flickering of the selected item on the drop down menu. If the drop down menu is opened by a pen click, hovering on top of the sub menu works correctly without any flickering.


I do not see anything like that, which probably means I am not testing correctly.

Also, can you test the same thing with "pre-pen" U++?

Mirek
Re: Using Pen with U++ [message #56613 is a reply to message #56612] Mon, 29 March 2021 12:33 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Mirek,

I did a video clip portraying the menu highlight flickering issue. Sent a PM on that.

There is no such anomaly on pre-pen U++.

Best regards,

Tom
Re: Using Pen with U++ [message #56614 is a reply to message #56613] Mon, 29 March 2021 13:57 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Tom1 wrote on Mon, 29 March 2021 12:33
Mirek,

I did a video clip portraying the menu highlight flickering issue. Sent a PM on that.

There is no such anomaly on pre-pen U++.

Best regards,

Tom


Well, all works fine with xp-pen (again...).

If you deactivate Windows Ink for tablet, what does it do?

Does it mean it now does those weird click animations (extending circle) even for mouse?

Mirek
Re: Using Pen with U++ [message #56615 is a reply to message #56614] Mon, 29 March 2021 14:36 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
The click animations are never present with mouse.

When using Windows Ink -mode for Wacom, I get those click animations for pen.

When I disable Windows Ink -mode for Wacom, the thing starts to work exactly like mouse:
+ no click animations
+ immediate response with drags (i.e. no annoying 2 cm delay)
- NO Pen() event. Everything comes in as MouseMove, LeftDown, LeftUp... (This likely means there is no WM_POINTER* messages and everything is already translated to WM_MOUSEMOVE, WM_LBUTTONDOWN,... etc.)
- NO pressure detection either due to missing WM_POINTER* -messages.

So, using Windows Ink -mode is a must.

Best regards,

Tom
Re: Using Pen with U++ [message #56616 is a reply to message #56615] Mon, 29 March 2021 15:35 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Well, that means that in the movie, you have used pen to open the menu, right?

Does this disbehave with mouse too? (Without animation?)

What happens if you comment out CtrlCore/Win32Proc.cpp:74?

Mirek
Re: Using Pen with U++ [message #56617 is a reply to message #56616] Mon, 29 March 2021 15:50 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
mirek wrote on Mon, 29 March 2021 16:35
Well, that means that in the movie, you have used pen to open the menu, right?

Does this disbehave with mouse too? (Without animation?)

What happens if you comment out CtrlCore/Win32Proc.cpp:74?

Mirek


1. Yes, I used pen throughout the video.

2. With mouse it works perfectly OK. There is no click animation with mouse.

3. Commenting out:
//	POINT p;
//	if(::GetCursorPos(&p))
		//CurrentMousePos = p;
Does not change anything.

Best regards,

Tom
Re: Using Pen with U++ [message #56618 is a reply to message #56617] Mon, 29 March 2021 16:01 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Tom1 wrote on Mon, 29 March 2021 15:50
mirek wrote on Mon, 29 March 2021 16:35
Well, that means that in the movie, you have used pen to open the menu, right?

Does this disbehave with mouse too? (Without animation?)

What happens if you comment out CtrlCore/Win32Proc.cpp:74?

Mirek


1. Yes, I used pen throughout the video.

2. With mouse it works perfectly OK. There is no click animation with mouse.

3. Commenting out:
//	POINT p;
//	if(::GetCursorPos(&p))
		//CurrentMousePos = p;
Does not change anything.

Best regards,

Tom


Pity, I was almost sure it must be related...

OK. The place that says whether the item is highlighted or not is

CtrlLib/MenuItem.cpp:267

Putting some DDUMPs for parts of that complex condition should reveal the source of oscilation.

Mirek
Re: Using Pen with U++ [message #56619 is a reply to message #56618] Mon, 29 March 2021 16:20 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Logging the changes shows that it's HasFocus() and especially HasMouse() that oscillates:
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+    32 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+    31 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+    31 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+    31 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+    32 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+    31 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+    31 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+    31 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true


Best regards,

Tom
Re: Using Pen with U++ [message #56620 is a reply to message #56619] Mon, 29 March 2021 16:54 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Tom1 wrote on Mon, 29 March 2021 16:20
Logging the changes shows that it's HasFocus() and especially HasMouse() that oscillates:
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+    32 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+    31 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+    31 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+    31 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+    32 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+    31 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+    31 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+    31 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true


Best regards,

Tom


Frankly, not sure what to do next... Sad
Re: Using Pen with U++ [message #56621 is a reply to message #56620] Mon, 29 March 2021 17:04 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Do you have Windows Ink enabled with your XP-PEN? If not, please do. You might then see the click animations and experience the drag lag. Maybe the menu issue shows itself then...(?)

BR,

Tom
Re: Using Pen with U++ [message #56622 is a reply to message #56621] Mon, 29 March 2021 17:18 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Thinking about it, as hovering with pen has no trouble, it must be an issue with 'pendown' not comparable to left mouse button being down. It might be partly identified as left mouse button being pressed and partly not, giving mixed messages about the state.

This is something that partially prevents RectTracker from being used with/from Pen() interface. (Which is still a main concern for me...)

Best regards,

Tom
Re: Using Pen with U++ [message #56623 is a reply to message #56622] Mon, 29 March 2021 17:29 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
OK, I logged some MEvent0 coordinates and tracked for mouseCtrl changes. It seems this is flipping mouseCtrl a lot:
[+     0 ms] WM_POINTERUPDATE
[+     0 ms] MEvent0 [141, 199]
[+     0 ms] WM_POINTERUPDATE
[+     0 ms] MEvent0 [141, 199]
[+     0 ms] WM_POINTERUPDATE
[+     0 ms] MEvent0 [141, 199]
[+     0 ms] HasMouse() = false
[+     0 ms] MEvent0 [141, 199]
[+     0 ms] WM_POINTERUPDATE
[+     0 ms] MEvent0 [141, 199]
[+     0 ms] WM_POINTERUPDATE
[+     0 ms] MEvent0 [142, 199]
[+     0 ms] MEvent0 [142, 199]
[+     0 ms] MEvent0 [142, 199]
[+     0 ms] WM_MOUSEMOVE
[+     0 ms] MEvent0 [139, 21]
[+     0 ms] mouseCtrl != this
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] MEvent0 [139, 21]
[+    31 ms] WM_POINTERUPDATE
[+     0 ms] MEvent0 [142, 199]
[+     0 ms] mouseCtrl != this
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] WM_POINTERUPDATE
[+     0 ms] MEvent0 [142, 199]
[+     0 ms] WM_POINTERUPDATE
[+     0 ms] MEvent0 [142, 199]
[+     0 ms] HasMouse() = false
[+     0 ms] MEvent0 [142, 199]
[+    16 ms] WM_POINTERUPDATE
[+     0 ms] MEvent0 [143, 199]
[+     0 ms] MEvent0 [143, 199]
[+     0 ms] MEvent0 [143, 199]
[+     0 ms] WM_MOUSEMOVE
[+     0 ms] MEvent0 [140, 21]
[+     0 ms] mouseCtrl != this
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] MEvent0 [140, 21]
[+    16 ms] WM_POINTERUPDATE
[+     0 ms] MEvent0 [143, 199]
[+     0 ms] mouseCtrl != this
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] WM_POINTERUPDATE
[+     0 ms] MEvent0 [143, 199]


Please note that pen is nearly stationary during this.

Best regards,

Tom

EDIT: Added WM_POINTERUPDATE and WM_MOUSEMOVE markers to the log, so that we can identify that the incompatible coordinates are coming from respective sources.

[Updated on: Mon, 29 March 2021 17:35]

Report message to a moderator

Re: Using Pen with U++ [message #56624 is a reply to message #56621] Mon, 29 March 2021 18:17 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Tom1 wrote on Mon, 29 March 2021 17:04
Do you have Windows Ink enabled with your XP-PEN? If not, please do. You might then see the click animations and experience the drag lag. Maybe the menu issue shows itself then...(?)

BR,

Tom


I have it enabled, I see the animation, but no problems.
Re: Using Pen with U++ [message #56626 is a reply to message #56624] Mon, 29 March 2021 20:41 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Mirek,

I'm almost sure this problem is about CtrlCore not entirely knowing about pen down condition. In a way, this resembles the ::GetCursorPos() issue you just fixed, where ::GetCursorPos() was not entirely aware of pen position, but only knew it after default processing. In this case GetMouseLeft() asks Windows for the left button state, but pen down is not the same as left mouse button in this case and is not detected. E.g. mouseCtrl and captureCtrl may be affected by this fact.

Again, I'm not familiar enough with the CtrlCore to make it properly aware about pen down condition. Can you improve the 'pen down awareness' of CtrlCore?

I tried:
static bool pendown=false;
bool GetMouseLeft()   { return pendown || (!!(GetKeyStateSafe(VK_LBUTTON) & 0x8000)); }

and updating the flag with WM_POINTERDOWN/WM_POINTERDOWN, but this was not enough.

Best regards,

Tom
Re: Using Pen with U++ [message #56629 is a reply to message #56626] Mon, 29 March 2021 22:02 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Hi Mirek,

See the switching Ctrls/hwnds for WM_POINTER and WM_MOUSEMOVE messages while on top of menu:
[+     0 ms] WM_MOUSEMOVE  N3Upp7MenuBarE  : 0x6a82880 (hwnd 0xd3009a)
[+     0 ms] Ctrl::DoMouse() [141, 302]
[+     0 ms] MEvent0 [138, 19]
[+     0 ms] mouseCtrl != this
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] MEvent0 [138, 19]
[+    15 ms] WM_POINTERUPDATE 5UWord  : 0x6b88070 (hwnd 0x7c02b4)
[+     0 ms] Ctrl::DoMouse() [141, 343]
[+     0 ms] MEvent0 [141, 197]
[+     0 ms] mouseCtrl != this
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] WM_POINTERUPDATE 5UWord  : 0x6b88070 (hwnd 0x7c02b4)
[+     0 ms] Ctrl::DoMouse() [142, 343]
[+     0 ms] MEvent0 [142, 197]
[+     0 ms] MEvent0 [142, 197]
[+    16 ms] MEvent0 [142, 197]
[+     0 ms] WM_MOUSEMOVE  N3Upp7MenuBarE  : 0x6a82880 (hwnd 0xd3009a)
[+     0 ms] Ctrl::DoMouse() [142, 302]
[+     0 ms] MEvent0 [139, 19]
[+     0 ms] mouseCtrl != this
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true

Although not shown here, the screen coordinates come in right for both events, but the translation differs in DoMouse() because the events end up in different Ctrls/hwnds. Therefore, also local coordinates mismatch. As you can see, WM_POINTERUPDATE lands in main window, whereas WM_MOUSEMOVE goes to drop down menu just as it should.

Hope this helps...

Best regards,

Tom

EDIT: Plain hovering on an open drop down menu makes both WM_POINTERUPDATE and WM_MOUSEMOVE land in the drop down menu:
[+     0 ms] WM_POINTERUPDATE N3Upp7MenuBarE  : 0x6a82880 (hwnd 0xb10064)
[+     0 ms] Ctrl::DoMouse() [124, 302]
[+     0 ms] MEvent0 [121, 19]
[+     0 ms] MEvent0 [121, 19]
[+     0 ms] MEvent0 [121, 19]
[+     0 ms] WM_MOUSEMOVE  N3Upp7MenuBarE  : 0x6a82880 (hwnd 0xb10064)
[+     0 ms] Ctrl::DoMouse() [124, 302]
[+     0 ms] MEvent0 [121, 19]
[+     0 ms] MEvent0 [121, 19]
[+    16 ms] MEvent0 [121, 19]
[+     0 ms] MEvent0 [121, 19]
[+     0 ms] WM_POINTERUPDATE N3Upp7MenuBarE  : 0x6a82880 (hwnd 0xb10064)
[+     0 ms] Ctrl::DoMouse() [124, 302]
[+     0 ms] MEvent0 [121, 19]
[+     0 ms] MEvent0 [121, 19]
[+     0 ms] WM_POINTERUPDATE N3Upp7MenuBarE  : 0x6a82880 (hwnd 0xb10064)
[+     0 ms] Ctrl::DoMouse() [123, 302]
[+     0 ms] MEvent0 [120, 19]
[+     0 ms] MEvent0 [120, 19]
[+     0 ms] MEvent0 [120, 19]
[+     0 ms] WM_MOUSEMOVE  N3Upp7MenuBarE  : 0x6a82880 (hwnd 0xb10064)
[+     0 ms] Ctrl::DoMouse() [123, 302]
[+     0 ms] MEvent0 [120, 19]
[+     0 ms] MEvent0 [120, 19]
[+    16 ms] MEvent0 [120, 19]
[+     0 ms] MEvent0 [120, 19]
[+     0 ms] WM_POINTERUPDATE N3Upp7MenuBarE  : 0x6a82880 (hwnd 0xb10064)
[+     0 ms] Ctrl::DoMouse() [123, 301]


Drag is the difference...

[Updated on: Mon, 29 March 2021 22:08]

Report message to a moderator

Re: Using Pen with U++ [message #56630 is a reply to message #56629] Tue, 30 March 2021 11:21 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Tom1 wrote on Mon, 29 March 2021 22:02
Hi Mirek,

See the switching Ctrls/hwnds for WM_POINTER and WM_MOUSEMOVE messages while on top of menu:


Looks like Wacom sends WM_POINTER to the window that has keyboard focus...

Can you add something like DDUMP(Name(GetFocusCtrl()) before WM_MOUSEMOVE / WM_POINT... ?

That said, the true reason is perhaps that Pen is altering mouseCtrl. That should be fixable...

Mirek

[+     0 ms] WM_MOUSEMOVE  N3Upp7MenuBarE  : 0x6a82880 (hwnd 0xd3009a)
[+     0 ms] Ctrl::DoMouse() [141, 302]
[+     0 ms] MEvent0 [138, 19]
[+     0 ms] mouseCtrl != this
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true
[+     0 ms] HasMouse() = true
[+     0 ms] MEvent0 [138, 19]
[+    15 ms] WM_POINTERUPDATE 5UWord  : 0x6b88070 (hwnd 0x7c02b4)
[+     0 ms] Ctrl::DoMouse() [141, 343]
[+     0 ms] MEvent0 [141, 197]
[+     0 ms] mouseCtrl != this
[+     0 ms] HasFocus() = false
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] HasMouse() = false
[+     0 ms] HasMouse() = true
[+     0 ms] WM_POINTERUPDATE 5UWord  : 0x6b88070 (hwnd 0x7c02b4)
[+     0 ms] Ctrl::DoMouse() [142, 343]
[+     0 ms] MEvent0 [142, 197]
[+     0 ms] MEvent0 [142, 197]
[+    16 ms] MEvent0 [142, 197]
[+     0 ms] WM_MOUSEMOVE  N3Upp7MenuBarE  : 0x6a82880 (hwnd 0xd3009a)
[+     0 ms] Ctrl::DoMouse() [142, 302]
[+     0 ms] MEvent0 [139, 19]
[+     0 ms] mouseCtrl != this
[+     0 ms] HasMouse() = false
[+     0 ms] HasFocus() = true

Although not shown here, the screen coordinates come in right for both events, but the translation differs in DoMouse() because the events end up in different Ctrls/hwnds. Therefore, also local coordinates mismatch. As you can see, WM_POINTERUPDATE lands in main window, whereas WM_MOUSEMOVE goes to drop down menu just as it should.

Hope this helps...

Best regards,

Tom

EDIT: Plain hovering on an open drop down menu makes both WM_POINTERUPDATE and WM_MOUSEMOVE land in the drop down menu:
[+     0 ms] WM_POINTERUPDATE N3Upp7MenuBarE  : 0x6a82880 (hwnd 0xb10064)
[+     0 ms] Ctrl::DoMouse() [124, 302]
[+     0 ms] MEvent0 [121, 19]
[+     0 ms] MEvent0 [121, 19]
[+     0 ms] MEvent0 [121, 19]
[+     0 ms] WM_MOUSEMOVE  N3Upp7MenuBarE  : 0x6a82880 (hwnd 0xb10064)
[+     0 ms] Ctrl::DoMouse() [124, 302]
[+     0 ms] MEvent0 [121, 19]
[+     0 ms] MEvent0 [121, 19]
[+    16 ms] MEvent0 [121, 19]
[+     0 ms] MEvent0 [121, 19]
[+     0 ms] WM_POINTERUPDATE N3Upp7MenuBarE  : 0x6a82880 (hwnd 0xb10064)
[+     0 ms] Ctrl::DoMouse() [124, 302]
[+     0 ms] MEvent0 [121, 19]
[+     0 ms] MEvent0 [121, 19]
[+     0 ms] WM_POINTERUPDATE N3Upp7MenuBarE  : 0x6a82880 (hwnd 0xb10064)
[+     0 ms] Ctrl::DoMouse() [123, 302]
[+     0 ms] MEvent0 [120, 19]
[+     0 ms] MEvent0 [120, 19]
[+     0 ms] MEvent0 [120, 19]
[+     0 ms] WM_MOUSEMOVE  N3Upp7MenuBarE  : 0x6a82880 (hwnd 0xb10064)
[+     0 ms] Ctrl::DoMouse() [123, 302]
[+     0 ms] MEvent0 [120, 19]
[+     0 ms] MEvent0 [120, 19]
[+    16 ms] MEvent0 [120, 19]
[+     0 ms] MEvent0 [120, 19]
[+     0 ms] WM_POINTERUPDATE N3Upp7MenuBarE  : 0x6a82880 (hwnd 0xb10064)
[+     0 ms] Ctrl::DoMouse() [123, 301]


Drag is the difference...[/quote]
Re: Using Pen with U++ [message #56631 is a reply to message #56629] Tue, 30 March 2021 11:26 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Try CtrlCore/CtrlMouse.cpp:320:

if(e != PEN && mouseCtrl != this) {
Re: Using Pen with U++ [message #56632 is a reply to message #56631] Tue, 30 March 2021 11:36 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
mirek wrote on Tue, 30 March 2021 12:26
Try CtrlCore/CtrlMouse.cpp:320:

if(e != PEN && mouseCtrl != this) {

The focusCtrl is switching between the menubar and the menuitem regardless the above change. The logs are taken just before DoMouse call in WM_MOUSEMOVE and WM_POINTERUPDATE:
[+     0 ms] WM_MOUSEMOVE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+    16 ms] WM_POINTERUPDATE N3Upp8MenuItemE  : 0x6c60c60 (parent N3Upp7BarPaneE)
[+     0 ms] WM_POINTERUPDATE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+     0 ms] WM_POINTERUPDATE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+    15 ms] WM_POINTERUPDATE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+     0 ms] WM_POINTERUPDATE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+    16 ms] WM_POINTERUPDATE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+     0 ms] WM_POINTERUPDATE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+    15 ms] WM_POINTERUPDATE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+     0 ms] WM_POINTERUPDATE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+     0 ms] WM_MOUSEMOVE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+    16 ms] WM_POINTERUPDATE N3Upp8MenuItemE  : 0x6c60c60 (parent N3Upp7BarPaneE)
[+     0 ms] WM_POINTERUPDATE N3Upp8MenuItemE  : 0x6c60c60 (parent N3Upp7BarPaneE)
[+    16 ms] WM_POINTERUPDATE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+     0 ms] WM_POINTERUPDATE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+     0 ms] WM_MOUSEMOVE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+    15 ms] WM_POINTERUPDATE N3Upp8MenuItemE  : 0x6c60c60 (parent N3Upp7BarPaneE)
[+     0 ms] WM_POINTERUPDATE N3Upp8MenuItemE  : 0x6c60c60 (parent N3Upp7BarPaneE)
[+    16 ms] WM_POINTERUPDATE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+     0 ms] WM_POINTERUPDATE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+     0 ms] WM_MOUSEMOVE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+    16 ms] WM_POINTERUPDATE N3Upp8MenuItemE  : 0x6c60c60 (parent N3Upp7BarPaneE)
[+     0 ms] WM_POINTERUPDATE N3Upp8MenuItemE  : 0x6c60c60 (parent N3Upp7BarPaneE)
[+    15 ms] WM_POINTERUPDATE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+     0 ms] WM_POINTERUPDATE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+     0 ms] WM_MOUSEMOVE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+    16 ms] WM_POINTERUPDATE N3Upp8MenuItemE  : 0x6c60c60 (parent N3Upp7BarPaneE)
[+     0 ms] WM_POINTERUPDATE N3Upp8MenuItemE  : 0x6c60c60 (parent N3Upp7BarPaneE)
[+    15 ms] WM_POINTERUPDATE N3Upp8MenuItemE  : 0x6c60c60 (parent N3Upp7BarPaneE)
[+     0 ms] WM_POINTERUPDATE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+     0 ms] WM_MOUSEMOVE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+    16 ms] WM_POINTERUPDATE N3Upp8MenuItemE  : 0x6c60c60 (parent N3Upp7BarPaneE)
[+     0 ms] WM_POINTERUPDATE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+     0 ms] WM_POINTERUPDATE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+     0 ms] WM_MOUSEMOVE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+    16 ms] WM_POINTERUPDATE N3Upp8MenuItemE  : 0x6c60c60 (parent N3Upp7BarPaneE)
[+    15 ms] WM_POINTERUPDATE N3Upp8MenuItemE  : 0x6c60c60 (parent N3Upp7BarPaneE)
[+     0 ms] WM_POINTERUPDATE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)
[+     0 ms] WM_MOUSEMOVE N3Upp7BarPaneE  : 0x6bc2978 (parent N3Upp7MenuBarE)


Best regards,

Tom

EDIT: Fixed content.

[Updated on: Tue, 30 March 2021 11:41]

Report message to a moderator

Re: Using Pen with U++ [message #56633 is a reply to message #56632] Tue, 30 March 2021 12:00 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
OK, I tried to completely separate Pen from Mouse now. Please try the trunk.

Mirek
Re: Using Pen with U++ [message #56635 is a reply to message #56633] Tue, 30 March 2021 12:44 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Hi,

Thank you Mirek! Well done! Now the menus work beautifully.

Can you take a look at the attached RectTracker testcase? It includes my Sketcher class which inherits RectTracker. In order to draw short detailed curves with freehand (i.e. Alt+PenDrag), Pen() support is needed in RectTracker. The 2 cm drag threshold with Wacom prevents relying on mouse processing (i.e. // 2. option in comment).

Thanks and best regards,

Tom



  • Attachment: main.cpp
    (Size: 5.46KB, Downloaded 233 times)
Re: Using Pen with U++ [message #56637 is a reply to message #56635] Tue, 30 March 2021 15:26 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Hi Mirek,

The following changes would add Pen support to RectTracker (and the inherited Sketcher).

Add to RectTracker in CtrlCore.h:

public:
	virtual bool  Pen(Point p, const PenInfo &pn, dword keyflags);
	virtual void  DoMouseMove(Point p, dword);

protected:
	int				pointer;


Changes in LocalLoop.cpp:
RectTracker::RectTracker(Ctrl& master)
{
	pointer=Null; // << ADD THIS IN CONSTRUCTOR

...

bool  RectTracker::Pen(Point p, const PenInfo &pn, dword keyflags){ // ADD Pen() here
	if(IsNull(pointer)) pointer=1;
	if(pointer!=1) return false;

	switch(pn.action){
		case 0:
			DoMouseMove(p, keyflags);
			break;
		case PEN_DOWN:
			LeftDown(p, keyflags);
			break;
		case PEN_UP:
			LeftUp(p, keyflags);
			break;
	}
	return true;
}

void RectTracker::MouseMove(Point mp, dword){ // ADD NEW MouseMove here
	if(IsNull(pointer)) pointer=2;
	if(pointer!=2) return;
	DoMouseMove(mp,0);
}

void RectTracker::DoMouseMove(Point mp, dword) // RENAMED ORIGINAL MouseMove to DoMouseMove
{

... THIS IS THE ORIGINAL MouseMove() code here ...


Changes in Win32Proc.cpp:
static bool pendown=false; // ADD
bool GetMouseLeft()   { return pendown || !!(GetKeyStateSafe(VK_LBUTTON) & 0x8000); } // ADD 'pendown ||' here

...

				if(message == WM_POINTERUPDATE && GetPointerPenInfoHistory(pointerId, &hc, ppit)) {
					bool processed = false;
					for(int i = hc - 1; i >= 0; i--) {
						ProcessPenInfo(ppit[i]);
						POINT hp = ppit[i].pointerInfo.ptPixelLocation;
						CurrentMousePos =  hp; // << ADD UPDATING HERE
						ScreenToClient(hwnd, &hp);
						pen.history = (bool)i;
						processed = DoPen(hp);
					}

...

				switch(message) {
				case WM_POINTERDOWN:
					pendown=true; // << ADD set pendown here
					pen.action = PEN_DOWN;
					ClickActivateWnd();
					break;
				case WM_POINTERUP:
					pendown=false; // << ADD set pendown here
					pen.action = PEN_UP;
					break;
				}



The updated testcase including modified Sketcher is attached in main2.cpp.

Would this be acceptable, or do you have a more elegant solution?

Best regards,

Tom
  • Attachment: main2.cpp
    (Size: 5.27KB, Downloaded 222 times)
Re: Using Pen with U++ [message #56644 is a reply to message #56637] Tue, 30 March 2021 23:34 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1432
Registered: December 2006
Ultimate Contributor
Upp build has been broken again. Most likely, this is not related to Pen stuff, but still ...
./umk reference SuggestCtrl CLANG -bus
/home/buildbot/worker/l-upp/build/reference/SuggestCtrl/main.cpp:54:21: error: address of overloaded function 'CharFilterToUpperAscii' is ambiguous
        ctrl.CompareFilter(CharFilterToUpperAscii);
                           ^~~~~~~~~~~~~~~~~~~~~~
/home/buildbot/worker/l-upp/build/reference/SuggestCtrl/main.cpp:5:12: note: candidate function
inline int CharFilterToUpperAscii(int c)
           ^
/home/buildbot/worker/l-upp/build/uppsrc/Core/String.h:954:5: note: candidate function
int CharFilterToUpperAscii(int c);
    ^
/home/buildbot/worker/l-upp/build/uppsrc/CtrlLib/SuggestCtrl.h:39:35: note: passing argument to parameter 'filter' here
        SuggestCtrl& CompareFilter(int (*filter)(int c))  { compare_filter = filter; return *this; }
                                         ^
1 error generated.


Regards,
Novo
Re: Using Pen with U++ [message #56647 is a reply to message #56637] Wed, 31 March 2021 10:37 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Mirek,

Something is preventing delivery of Pen() call to widgets inside a Splitter. Here's a testcase:
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct Canvas: Ctrl {
	Point pos;
	
	Vector<Vector<Tuple<double, Pointf>>> drawing;

	PenInfo	pen;

	Canvas(){
		pos=Null;
		Zero(pen);
	}
	
	virtual bool Pen(Point p, const PenInfo& pn, dword keyflags) override {
		pen=pn;
		
		switch(pn.action){
			case PEN_DOWN:
				drawing.Add().Add(MakeTuple(pn.pressure, p));
				break;
			case 0: // Move
				if(!!pn.pressure && !drawing.IsEmpty()) drawing.Top().Add(MakeTuple(pn.pressure, p));
			case PEN_UP: // Finish
				Refresh();
				break;
		}
		return true;
	}

	virtual void Paint(Draw& w0) override {
		DrawPainter w(w0, GetSize());
		w.Co();
		w.Clear(SColorPaper());
		
		w.LineCap(LINECAP_ROUND);
		for(const auto& stroke : drawing)
			if(stroke.GetCount())
				for(int i = 0; i < stroke.GetCount() - 1; i++) {
					w.Move(stroke[i].b);
					w.Line(stroke[i + 1].b);
					w.Stroke(DPI(20) * stroke[i].a, Black());
				}
		
		int fcy = GetStdFontCy();
		int y = 10;
		auto Text = [&] (const String& text) {
			w.DrawText(10, y, text);
			y += fcy;
		};
		Text(AsString(pos));
		Text(String() << "Pressure: " << pen.pressure);
		Text(String() << "Rotation: " << pen.rotation);
		Text(String() << "Tilt: " << pen.tilt);
		Text(String() << "Barrel: " << pen.barrel);
		Text(String() << "Inverted: " << pen.inverted);
		Text(String() << "Eraser: " << pen.eraser);
	}
};

struct MyApp : TopWindow {
	Canvas c1;
	Canvas c2;
	Splitter s;
	
	MyApp(){
		Add(s.Horz(c1,c2));
	}
};

GUI_APP_MAIN { MyApp().Run(); }


Best regards,

Tom

EDIT: Fixed testcase crash when drawing across the splitter wall.

[Updated on: Wed, 31 March 2021 13:43]

Report message to a moderator

Re: Using Pen with U++ [message #56648 is a reply to message #56647] Wed, 31 March 2021 13:14 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Mirek,

How about this change in Ctrl::WindowProc() in Win32Proc.cpp?:
			auto DoPen = [&](Point p) {
				GuiLock __;
				eventCtrl = this;
				Ctrl *q = this;
				for(Ctrl *t = q; t; t=q->ChildFromPoint(p)) q = t;
				bool b = q->Pen(p, pen, GetMouseFlags());
				SyncCaret();
				return b;
			};

Now the for loop propagates the Pen to last child, and the Pen works in the above testcase.

Best regards,

Tom
Re: Using Pen with U++ [message #56649 is a reply to message #56648] Wed, 31 March 2021 13:46 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Hi,

Another issue: The mouse cursor in the above testcase does not get updated when using pen. If the cursor crosses the splitter wall, the wall -specific cursor will remain even when pen hovers on top of the drawing canvas. The cursor updating code must be absent in the DoPen function...

EDIT: How about this?
			auto DoPen = [&](Point p) {
				GuiLock __;
				eventCtrl = this;
				Ctrl *q = this;
				for(Ctrl *t = q; t; t=q->ChildFromPoint(p)) q = t;
				bool b = q->Pen(p, pen, GetMouseFlags());
				SyncCaret();
				Image m = CursorOverride();
				if(IsNull(m)) SetMouseCursor(q->CursorImage(p,GetMouseFlags()));
				else SetMouseCursor(m);
				return b;
			};


Best regards,

Tom

[Updated on: Wed, 31 March 2021 14:17]

Report message to a moderator

Re: Using Pen with U++ [message #56650 is a reply to message #56649] Wed, 31 March 2021 15:03 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
And one more issue shown with the testcase:

The Splitter wall cannot be moved with the pen. Again, the Splitter does not get capture until the pen has moved 2 cm, but unfortunately at that time the pen is no longer on top of the wall, but rather 2 cm away from it. If I drag back and cross the Splitter wall 2 or more centimeters away from the original starting point, it gets captured and the wall starts moving.

Best regards,

Tom
Re: Using Pen with U++ [message #56656 is a reply to message #56650] Thu, 01 April 2021 13:53 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Hi Mirek,

Just noticed that SetCapture()/ReleaseCapture() was not working with Pen. Here's a fix for that:
			auto DoPen = [&](Point p) {
				GuiLock __;
				eventCtrl = this;
				Ctrl *q = this;
				if(captureCtrl){
					q=captureCtrl;
					p+=GetScreenRect().TopLeft()-captureCtrl->GetScreenRect().TopLeft();
				}
				else for(Ctrl *t = q; t; t=q->ChildFromPoint(p)) q = t;
				
				bool b = q->Pen(p, pen, GetMouseFlags());
				SyncCaret();
				Image m = CursorOverride();
				if(IsNull(m)) SetMouseCursor(q->CursorImage(p,GetMouseFlags()));
				else SetMouseCursor(m);
				return b;
			};


Best regards,

Tom

EDIT: Fixed coordinate offset in captureCtrl...

[Updated on: Thu, 01 April 2021 15:41]

Report message to a moderator

Re: Using Pen with U++ [message #56657 is a reply to message #56656] Thu, 01 April 2021 16:22 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Mirek,

OK, it seems the following (along with the previous changes) fixes Splitter behavior with pen.

Splitter.h:
class Splitter : public Ctrl {
	int            pointer;
public:
	virtual void   Layout();
	virtual void   Paint(Draw& draw);
	virtual void   DoMouseMove(Point p, dword keyflags);
	virtual void   MouseMove(Point p, dword keyflags);
	virtual bool   Pen(Point p, const PenInfo &pn, dword keyflags);
	virtual void   LeftDown(Point p, dword keyflags);
	virtual void   LeftUp(Point p, dword keyflags);
...


Splitter.cpp:
...
void   Splitter::MouseMove(Point p, dword) {
	if(pointer==2) DoMouseMove(p,0);
}

void   Splitter::DoMouseMove(Point p, dword) {
	if(HasCapture() && mouseindex >= 0 && mouseindex < pos.GetCount()) {
		SetPos(ClientToPos(p), mouseindex);
		Refresh();
		WhenAction();
	}
}

bool   Splitter::Pen(Point p, const PenInfo &pn, dword keyflags){
	switch(pn.action){
		case 0:
			if(pointer==1 && !pn.history) DoMouseMove(p, keyflags);
			break;
		case PEN_DOWN:
			if(IsNull(pointer)) pointer=1;
			LeftDown(p, keyflags);
			break;
		case PEN_UP:
			LeftUp(p, keyflags);
			break;
	}
	return true;
}

void   Splitter::LeftDown(Point p, dword) {
	if(IsNull(pointer)) pointer=2;
	SetCapture();
	Refresh();
	mouseindex = FindIndex(p);
}

int Splitter::FindIndex(Point client) const {
	int best = -1;
	int maxdist = chstyle->width;
	for(int i = 0; i < pos.GetCount(); i++) {
		int dist = abs((vert ? client.y : client.x) - PosToClient(pos[i]));
		if(dist <= maxdist) {
			best = i;
			maxdist = abs(dist);
		}
	}
	return best;
}

void   Splitter::LeftUp(Point p, dword keyflags) {
	pointer=Null;
	if(HasCapture())
		WhenSplitFinish();
	ReleaseCapture();
	Refresh();
}
...
Splitter::Splitter() {
	pointer = Null; // << Initialize here
	chstyle = NULL;
...

Best regards,

Tom
Re: Using Pen with U++ [message #56659 is a reply to message #56657] Thu, 01 April 2021 17:29 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Tom1 wrote on Thu, 01 April 2021 16:22
Mirek,

OK, it seems the following (along with the previous changes) fixes Splitter behavior with pen.

Splitter.h:
class Splitter : public Ctrl {
	int            pointer;
public:
	virtual void   Layout();
	virtual void   Paint(Draw& draw);
	virtual void   DoMouseMove(Point p, dword keyflags);
	virtual void   MouseMove(Point p, dword keyflags);
	virtual bool   Pen(Point p, const PenInfo &pn, dword keyflags);
	virtual void   LeftDown(Point p, dword keyflags);
	virtual void   LeftUp(Point p, dword keyflags);
...


Splitter.cpp:
...
void   Splitter::MouseMove(Point p, dword) {
	if(pointer==2) DoMouseMove(p,0);
}

void   Splitter::DoMouseMove(Point p, dword) {
	if(HasCapture() && mouseindex >= 0 && mouseindex < pos.GetCount()) {
		SetPos(ClientToPos(p), mouseindex);
		Refresh();
		WhenAction();
	}
}

bool   Splitter::Pen(Point p, const PenInfo &pn, dword keyflags){
	switch(pn.action){
		case 0:
			if(pointer==1 && !pn.history) DoMouseMove(p, keyflags);
			break;
		case PEN_DOWN:
			if(IsNull(pointer)) pointer=1;
			LeftDown(p, keyflags);
			break;
		case PEN_UP:
			LeftUp(p, keyflags);
			break;
	}
	return true;
}

void   Splitter::LeftDown(Point p, dword) {
	if(IsNull(pointer)) pointer=2;
	SetCapture();
	Refresh();
	mouseindex = FindIndex(p);
}

int Splitter::FindIndex(Point client) const {
	int best = -1;
	int maxdist = chstyle->width;
	for(int i = 0; i < pos.GetCount(); i++) {
		int dist = abs((vert ? client.y : client.x) - PosToClient(pos[i]));
		if(dist <= maxdist) {
			best = i;
			maxdist = abs(dist);
		}
	}
	return best;
}

void   Splitter::LeftUp(Point p, dword keyflags) {
	pointer=Null;
	if(HasCapture())
		WhenSplitFinish();
	ReleaseCapture();
	Refresh();
}
...
Splitter::Splitter() {
	pointer = Null; // << Initialize here
	chstyle = NULL;
...

Best regards,

Tom


In other words, have we failed again? Smile (The very moment you start fixing code in CtrlLib, it is failure...)

Mirek
Re: Using Pen with U++ [message #56660 is a reply to message #56659] Thu, 01 April 2021 18:01 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Well, I do not know... When using default (non-pen) processing, pen must be dragged 2 cm before WM_LBUTTONDOWN is first sent. Confused

I do not know if this is the reason why the Splitter wall does not get captured with SetCapture().

So, I'm not sure at all, if this is our/my failure or if it is Wacom or Microsoft issue... After all, a mouse drag effectively begins only few pixels away from the starting point while for wacom it takes 2 cm.

Best regards,

Tom

EDIT: More specifically: When I put the pen down on standard splitter and start dragging, the splitter first gets nothing. As pen proceeds on top of the adjacent Canvas, the Canvas receives Pen() move actions with pressure on. When pen has moved 2 cm, I would expect the splitter to finally react, but in fact it requires pen passing over the splitter wall at a range greater than 2 cm from the starting point in order for the capture to realize.

EDIT2: The reason for not getting the WM_LBUTTONDOWN is obviously the lack of default processing when all the WM_POINTER* are in fact processed in Canvas and end with return 0L; instead. However, if we let it do default processing, we will start getting some WM_MOUSEMOVEs too from pen even when WM_POINTERUPDATEs have actually been processed already.

Maybe this must be fixed on the application side then: If Pen() returns false for such moves when pen is not actively being used in the Canvas i.e. a pendown condition therein, then Splitter can work almost normally despite the 2 cm start-up threshold. Obviously, the MouseMove()s must be processed accordingly.

[Updated on: Thu, 01 April 2021 21:55]

Report message to a moderator

Re: Using Pen with U++ [message #56663 is a reply to message #56660] Thu, 01 April 2021 22:46 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
If all works with "pre-Pen-U++" (?), maybe we should try to get back to "pen is mouse" mode (no Pen method). Return 0L in pen handling.

The only problem then is how to implement "IsPen" method (we definitely need that one). I can do that with XP-PEN (quoted that a while back), but we need a realiable method that works for Wacom too.

Mirek
Re: Using Pen with U++ [message #56664 is a reply to message #56663] Thu, 01 April 2021 22:49 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Are you 100% sure this does not work with Wacom:

https://stackoverflow.com/questions/29857587/detect-if-wm-mo usemove-is-caused-by-touch-pen

?
Re: Using Pen with U++ [message #56666 is a reply to message #56664] Fri, 02 April 2021 08:26 Go to previous messageGo to previous message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
mirek wrote on Thu, 01 April 2021 23:49
Are you 100% sure this does not work with Wacom:

https://stackoverflow.com/questions/29857587/detect-if-wm-mo usemove-is-caused-by-touch-pen

?


Last time I tried it did not work. It was zero all the time. Since then, I have reinstalled the Wacom drivers.

Now I get: "GetMessageExtraInfo() = 4283520772" for pen and "GetMessageExtraInfo() = 0" for mouse. These are present for e.g. WM_MOUSEMOVE and WM_LBUTTONDOWN.

So, I may have made some stupid mistake last time or the driver re-installation may have had an effect.

Best regards,

Tom
Previous Topic: WString vs Grapheme Cluster idea (with possible flaw)
Next Topic: .gitignore
Goto Forum:
  


Current Time: Sun Jun 28 03:15:18 GMT+2 2026

Total time taken to generate the page: 0.01214 seconds