Get The Mouse Scroll Location Of A Bpatcher

Raphael Radna's icon

It would be helpful if I could get the horizontal scroll location of a bpatcher, ideally in js (e.g., if you were to scroll with the mouse 10 pixels to the right, you could somehow access the value "10" ). I see the "Patcher" object in js has a 'scrolloffset' property, but I haven't had any luck getting this to work with a bpatcher. Anybody know of a way to do this? Thanks.

LSka's icon

use [mousestate] in mode 1:

Max Patch
Copy patch and select New From Clipboard in Max.

put this in a bpatcher and it will give you mouse coordinates relative to the bpatcher position.
You may want to filter the values that are out of the desired range, and that can be done using [split]

Raphael Radna's icon

Thanks a lot, I think this will work if there's no JS solution

Roman Thilenius's icon


all "regular" objects (mousestate, lcd, pwindow, ubutton,) will use/give relatives values.

Steve Valentin's icon

mousestate doesnt not do that anymore it seems... some time ago i built myself a solution that gave out the mouse position when scrolling a bpatcher but this solution stopped working. mousestate gives out values now only when the mouse pointer is moving and not anymore when the mouse is still and only the background (bpatcher) moves while scrolling with two fingers on the trackpad. ...i guess with an update this must have been introduced. can anybody confirm?

Ian C.'s icon

The mousestate solution is OK for some stuff, you get the mouse point position (+ click, + delta states) and it's possible to adapt it for some situations. But if the user is scrolling through the mouse wheel, or a trackpad, then the scroll bar position gets lost. It's very annoying Max can't report the actual value of the scrollbar, even though we can use the wind object in JS to move it. This variable must be somewhere, no? There must be a way of getting it out. I hope there will be a way and that a Max update can fix that.

11OLSEN's icon

js: post(this.patcher.box.getboxattr("offset"));