Fanning Software Consulting

Using the Mouse Wheel in UNIX Widgets

QUESTION: I would like to be able to use my mouse wheel or mouse tracking ball to scroll IDL widget lists and text widgets. I know this is possible on Windows, but how can I do it in UNIX environments?

ANSWER: The answer is provided by JD Smith in a 22 January 2006 IDL newsgroup article.

IDL users of MacOSX/UNIX can enable this ever so useful functionality with a bit of Motif X resource hackery. Simply add the following lines of code to your ~/.Xdefaults file, restart X11 and IDL, and scroll away on lists and text widgets.

*XmList.baseTranslations: #augment Shift<Btn5Down>: ListNextItem()\n\
	Shift<Btn4Down>: ListPrevItem()\n\
	<Btn5Down>: ListNextPage()\n\
        <Btn4Down>: ListPrevPage()\n

*XmScrollBar.baseTranslations: #augment <Btn4Down>: 
IncrementUpOrLeft(0) IncrementUpOrLeft(1)\n\ <Btn5Down>: IncrementDownOrRight(0) IncrementDownOrRight(1)\n *XmText.baseTranslations: #augment Shift<Btn4Down>: page-left()\n\ Shift<Btn5Down>: page-right()\n\ <Btn4Down>: scroll-one-line-up()\n\ <Btn5Down>: scroll-one-line-down()\n

Those random back slashes and newline commands aren't line noise, they need to be included. Also, please note that the line above that starts out “*XmScrollBar.baseTranslations:” is a single line, with the line that follows it. (It is too long for this page, so I have had to break it unnaturally!)

In IDL widget lists, scroll does Page Up/Down, whereas shift-scroll moves the "dotted" selection by one. When the mouse is over the scrollbar itself, the scroll wheel moves a line at a time. Text widgets are similar.

Experience on a Macintosh

Nathaniel Cunningham tried this on his Max OS X machine and had this to report.

Thanks for the tip! I've been wanting this for ages.

For some reason, Shift doesn't work as a scroll modifier for me under OS X (10.4.4). I changed all instances of 'Shift' to 'Ctrl' and that works fine.

Also, I found my up/down scrolling was reversed in text widgets, so I interchanged <Btn4Down> and <Btn5Down> in the last two lines of your .Xdefaults code.

Web Coyote's Guide to IDL Programming