Scrollpanel + Mousewheel up/down?

BlitzMax Forums/MaxGUI Module/Scrollpanel + Mousewheel up/down?

Grisu(Posted 2013) [#1]
Hi,

I'm trying to attach mousewheel support to a scrollpanel. The following problems occur:

1. It takes several mouse clicks until the panel detects that the mousewheel (EVENT_MOUSEWHEEL) is used.
2. MouseZ() gives strange results for mousewheel up / down?
3. How to scroll the slider the "default" speed up / down accordingly?

Example code:


Grisu

|edit: For updated code


Henri(Posted 2013) [#2]
Hello,

1. If you use "ActivateGadget scrlMain" mousewheel seems to be registering right away

2 & 3. EventData() returns either-1 or 1 depending on the direction of the mousewheel. You could use ScrollScrollpanel() to scroll the amount needed.


-Henri


Grisu(Posted 2013) [#3]
Thanks for the informations. I updated my code above.

Is there a way to detect how much a listbox is scrollable (y-wise) on the users system? I'd love to "sync" the scrollspeed with the the listbox gadget.

The ActivateGadget() calls may interrupt other gadgets (Comboboxes etc) on the panel. Need to do some more testing on this.


Henri(Posted 2013) [#4]
The original problem with mousewheel not registering comes from panel not being active to receive mousewheel event. Labels don't emit this as you can see if you modify your label creating loop by adding:

SetGadgetColor(tmpLabel,Rnd(255),Rnd(255),Rnd(255))


And after you click between labels the panel is active again.


About the listbox-thing I'm not sure. You could count the number of gadgetitems in a listbox and then do a
SelectGadgetItem(listbox,index)
and the listbox would scroll to your selected index.


-Henri


Grisu(Posted 2013) [#5]
You're right about the labels. Shouldn't they be able to catch such events? :(

I've implemented a modified code into my app. If anyone wants to give it a try. Download: http://www.mediafire.com/?74rn4yjs4vg6ovt


col(Posted 2013) [#6]
Dear god!

I've just spent several hours scanning through only 1/10th of the available channels :D

Works great. What an awesome little player! Thankyou.

ps. Scrolling works ok here using Win8 on laptop.


Festay(Posted 2013) [#7]
The scrolling works fine here too (Win 8).

This is a fantastic piece of software. I love it's simplicity, it works really well, the only nitpick I have is that there didn't seem to be a way to search for a station (e.g. by typing). Keep up the good work!

Just out of interest, is this open source?

Update:
I've just been on the website which told me how to search...I'm embarrassed I didn't figure that out myself!


Grisu(Posted 2013) [#8]
Thanks for the feedback. If you would like to keep track of changes, please join the Facebook page as I don't post everything here.
Scolling doesn't work for me 100% properly. :/ Keep in mind that it only affects the Options, Credits and Station Editor panel. Scrollbars on listboxes work out of the box.

@Col: It takes much longer to update the station database. :)

@Festay: You can do a "Quick Search" by typing directly into the genre selection combobox ;) See: http://pocketradio.awardspace.info/faq_search.html
It's not open source. But I'm thankful and open-minded for every piece of support I get. - Might it even be an updated / new station file.

This project is already too time consuming for a freetime job.


col(Posted 2013) [#9]
I see.

Yes the bug shows up on the options selection.

On Win8 ( maybe Win7 too )...

Specifically for your example code above you need to change the If EventData() = - 1 Then to If EventData() < 0 Then for it to work, MS have changed the mouse wheel change rate for Touch so that you can 'flick' the mouse and visually see a deceleration of the mouse scroll speed.


Grisu(Posted 2013) [#10]
Seems to be a bug or user error. :/ I modified/simplified the example code bit. Only 2 labels are created and the mousewheel event still doesn't tigger on them. The same goes for checkboxes and comboboxes as well btw. When you min/max the window from the taskbar one can recheck the issue easily.



Is there at lest some way to detect if the user has mouse clicked on the scrollbar itself? So that I can activate the gadget for the panel accordingly. This might not be the greatest mousewheel support, but at least it would give a constant user experience.


Henri(Posted 2013) [#11]
There isn't a easy way to detect events on scrollbars, but it's possible atleast in Windows (don't no about others). But...

I modified your example a bit and if scrollbar detection isn't a must then...




-Henri


Captain Wicker (crazy hillbilly)(Posted 2013) [#12]
just spotted this thread. I was having this problem on OSX. Henri's example helped me. So Thanks! :)


col(Posted 2013) [#13]
So am I right in thinking you would want something to give focus automatically when you mouse over the scroll panel and its children therefore giving you the mousewheel event, and then, when the mouse moves out of the scroll panel, to return the focus to whatever had focus before?

Is so, something like this may work ( untested, just an idea )

Add

Global PrevGadget:TGadget outside of the main loop.

then within the loop have something like:-

Case EVENT_MOUSEENTER
	If Not PrevGadget
		PrevGadget = TGadget(EventSource())
		ActivateGadget PrevGadget
	EndIf

Case EVENT_MOUSELEAVE
	If PrevGadget <> ScrlMain And PrevGadget <> tmpClient And  PrevGadget <> tmpLabel And PrevGadget <> tmpLabel2
				ActivateGadget PrevGadget
		PrevGadget = Null
	EndIf


It is untested so may need a little work to get it right. Just a thought.


Grisu(Posted 2013) [#14]
If you have a small app Henri's approach is nice.

I modified Dave's code, as I have to deal with 10 panels and dozens of different gadgets on them. Hopefully this will work on all platforms. Please give it a shot if you can. I only tested this on Win7 so far.

Download: http://www.mediafire.com/download/3p4qgs8rp7vb88s/prp_win32.zip


Sub_Zero(Posted 2013) [#15]
Wow.. Very nice app :)