Scroll checklistbox by dragging?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
philjynx
Earned some good credits
Earned some good credits
Posts: 137
Joined: Tue Mar 06, 2018 6:00 pm

Scroll checklistbox by dragging?

Post by philjynx »

I'd like to be able to (on a touchscreen) scroll a checklistbox in the same way you would on Android. I imagine it is possible but do not know where to start to capture the 'mouse' movements.

Can anybody point me in the right direction?
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: Scroll checklistbox by dragging?

Post by PB »

philjynx wrote:I imagine it is possible but do not know where to start to capture the 'mouse' movements.
Have you looked into wxGestureEvent (/wxPanGestureEvent)?

I have no experience with it myself. It has been added quite recently and may not have been extensively tested, as there is not that many touch-enabled devices running wxWidgets.

But perhaps it may be worth checking out...
philjynx
Earned some good credits
Earned some good credits
Posts: 137
Joined: Tue Mar 06, 2018 6:00 pm

Re: Scroll checklistbox by dragging?

Post by philjynx »

PB wrote:
philjynx wrote:I imagine it is possible but do not know where to start to capture the 'mouse' movements.
Have you looked into wxGestureEvent (/wxPanGestureEvent)?

I have no experience with it myself. It has been added quite recently and may not have been extensively tested, as there is not that many touch-enabled devices running wxWidgets.

But perhaps it may be worth checking out...
Sounds promising, I'll have a looksee. Thank you.

Nowt coming up in my documentation, so I suspect I don't have it. :(
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: Scroll checklistbox by dragging?

Post by PB »

philjynx wrote:Nowt coming up in my documentation, so I suspect I don't have it. :(
It has been added in 3.1.1 (last December), its use is demonstrated in the Event sample.
coderrc
Earned some good credits
Earned some good credits
Posts: 141
Joined: Tue Nov 01, 2016 2:46 pm

Re: Scroll checklistbox by dragging?

Post by coderrc »

what I have done in the past is use the wxEVT_MOTION event, with the caveat that my system's touchscreen registers as a mouse. You may find that you need to bind the OnMotion function recursively starting with your parent container, otherwise if the drag starts on a text item, rather than the container itself, the motion may not register.

my OnMotion function looks something like

Code: Select all

int32_t dy = 0;
	if (event.Dragging() || event.LeftIsDown())
	{
		auto pos = wxGetMousePosition();
		dy = (m_lastMousePos.y) - (pos.y);
		if (abs(dy) > 5)
		{
			int cx;
			int cy;
			m_pnl_item_list->CalcUnscrolledPosition(0, dy, &cx, &cy);
			m_pnl_item_list->Scroll(-1, cy);
			m_lastMousePos = pos;
		}
		event.StopPropagation();
	}
where m_pnl_item_list is a wxScrolledWindow containing the list control
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Scroll checklistbox by dragging?

Post by ONEEYEMAN »

Hi,
What platform and wxWidgets version?
In our application we have a hardware which supports touch screen using the drivers (we don't have touchpads - more like a laptops).
We do run RHEL6 and there is no extra processing requires to do touch screen or scrolling.

Thank you.
Post Reply