Skip to main content
Inspiring
December 17, 2015
Question

mouse wheel input not registered [ScriptUI events]

  • December 17, 2015
  • 1 reply
  • 1434 views

Hello everybody,

I'm trying to make elements in a group move by using the mouse wheel / scroll wheel .

I can't find a way to make it do just that though. I have tried with various eventListeners for the mouse, but can't get any feedback.

It seems the only registered buttons are LMB, RMB and MMB-click.

Heres a small test-script for testing mouse input:

{

// AE mouse input

function ae_mouse_input_tester(thisObj){

  //== GUI ==//

  function GUI(thisObj){

  var builder = thisObj instanceof Panel ? thisObj : new Window("dialog", "Background Renderer", undefined,{borderless:false}, {resizable:true}) ;

  builder.onResizing = function(){

  builder.layout.layout(true)

  builder.layout.resize();

  }

  //-- USER INTERFACE --//

  var mWin = builder.add('group')

  mWin.orientation = 'column'

  mWin.size = [250,250]

  mWin.alignChildren = ['center','center']

  var btn1 = mWin.add('button',undefined,'button 1')

  var btn2 = mWin.add('button',undefined,'button 2')

  var scrl = mWin.add('scrollbar',undefined)

  scrl.alignment = ['fill','bottom']

  var log = mWin.add('StaticText',undefined,"console")

  log.alignment = ['fill','bottom']

  //-- EVENT HANDLERS --//

  //- Main Window

  // what's under the cursor

  mWin.addEventListener("mouseover",function(event){

  var target = event.target.toString()

  log.text = "target: "+target

  })

  // mouse button pressed

  mWin.addEventListener("mousedown",function(event){

  var mb = event.button

  switch (mb){

  case 0:

  log.text = "LMB v"

  break;

  case 1:

  log.text = "MMB v"

  break;

  case 2:

  log.text = "RMB v"

  break;

  default:

  log.text = mb

  }

  })

  // mouse button released

  mWin.addEventListener("mouseup",function(event){

  var mb = event.button

  switch (mb){

  case 0:

  log.text = "LMB ^"

  break;

  case 1:

  log.text = "MMB ^"

  break;

  case 2:

  log.text = "RMB ^"

  break;

  default:

  log.text = mb

  }

  })

  // mouse wheel NOT WORKING!!!!

  mWin.addEventListener("scrollwheel",function(event){

  log.text = event

  })

  //- Scrollbar

  scrl.onChange = function(){

  log.text = scrl.value

  }

  return builder;

  }

  var gui = GUI(thisObj)

  if (gui instanceof Window){

  gui.show()

  gui.center()

  }

}

ae_mouse_input_tester(this)

}

I'm using After Effects CC 2014 on a Windows 7 workstation.

This topic has been closed for replies.

1 reply

UQg
Legend
December 18, 2015

It doesnt seem that the wheel events are supported in ScriptUI. The (Adobe) JavaScript Tools Guide doesnt mention them.
The 'scrollwheel' event type is actually called 'wheel' (see http://www.w3.org/TR/DOM-Level-3-Events/#event-types-list),

it is an instance of WheelEvent (http://www.w3.org/TR/DOM-Level-3-Events/#event-type-wheel), which has no equivalent in ScriptUI.

The list of supported mouse event types in ScriptUI is given on page 154 of JavaScript Tools Guide CC.pdf:

mousedown
mouseup
mousemove
mouseover
mouseout
click (detail = 1 for single, 2 for double)


So to scroll something in ScriptUI, it seems that you'll have to add a scrollbar and click+drag the cursor.

Alternatively, it might be possible to implement arrow keys.


Thinking about it now, it might be the reason why the Object Model Viewer in ESTK does not respond to the scroll wheel.


Xavier

FynnayAuthor
Inspiring
December 23, 2015

Hi Xavier,

that's what I was afraid of. I checked out the w3 pages as well and, even though not documented by the javascript tools guide, tried them all out.

Like you said, they just don't seem to work. The middle mouse click however does work.

So I found a bunch of workarounds:

- I used the mousedown in conjunction with mousemove to make a middle-mouse-click-and-drag thing. Works pretty well. Annoying when on a laptop though.

- I added a scrollbar, which has a onChange() event, that reacts to the scrollwheel. So, you'd have to mouseover the scrollbar to use the scrollwheel, but when you do, it works like a charm.

- When said scrollbar has been activated once, you can use ( [shift]+ )[arrow up]/[arrow down] to move it even without the cursor hovering overit. At least until you click on something else in the window.


Thanks for the help/confirmation. At least now I know I'm not the only one, and not blind.


Have a good one,

Fynn