Wednesday, September 23, 2009

New plug-in: scrolling with middle button

My favorite way to scroll site contents in internet browsers is to press middle mouse button and slightly move mouse up or down. It's usually more convenient than rotating mouse wheel or grabbing scrollbar. This feature is supported by every popular browser but it's also being added to other applications (even the primitive Notepad in Windows has it!). I got used to it so much that I really miss it in Eclipse.

So I've done a little investigation to check whether it would be possible to add such a feature to Eclipse workbench. It turns out it would be very hard to do, as there's no general API in SWT to programmatically invoke scrolling. Only limited number of custom widgets provide methods that can do it. Fortunately, StyledText which is used by all text editors in Eclipse is one of them. This allowed me to prepare a plug-in that adds MMB scrolling at least to text editors. It's not much, but better than nothing. If you're interested, please visit the project page or go directly for download.

I'll be trying to hack other popular editors and viewers, so the list of scrollable elements may get longer in next versions. If you know something that may be useful for this task, please let me know :)


Christopher Daniel said...

Have you thought about opening a bug and contributing this to Eclipse?

Jacek Pospychala said...

nice, I was never thinking about it, but on windows, ThinkPad trackpoint buttons driver does that by default. This is of course impossible on Linux, where I could use your plug-in.

Mateusz Matela said...

Christopher: yeah, I considered this, but I don't think my plugin would make a valid contribution because 1) only one type of editor is supported which leads to inconsistent behavior, 2) the code contains some nasty hacks like using reflection to retrieve private fields, 3) a lot of linux users use MMB to paste text, so we have conflict (don't know how it looks on macs). So I think the downloadable plug-in is currently the best option.

dcjfm said...

Thank You very much!
That was exactly what I was missing in Eclipse on Ubuntu!

Anonymous said...

Found this post looking for a way to middle auto-scroll MS Paint the same as IE* - did not realize even Notepad has this function!!

Why not Paint, & how to achieve it in Paint? seriously, I use Paint for composing screengrab documents - light, fast, nothing extra to get in the way - mostly StrokeIT gestures + AHK hotkey bindings.

MouseImp Pro does it beautifully,
except that its keyhooks interfere with StrokeIt.

Several other AHK scripts send the cursor to grab the scroll bar, and this makes the cursor always want to jump to the bottom right corner of the screen.

Thanks for any suggestions !
- a seeker