Recently I've been looking at Povray, pyprocessing, and cfdg (version 3.0) as tools for creating digital images. I have branched two separate blogs where I mainly explore jruby + processing and processing.py

Thursday, 22 November 2012

Whither the MouseWheel in Processing-2.0

What really seems to have buggered things up just recently is the recent adoption of  jogl NEWT (Native Windowing Toolkit), which could be a showstopper for MouseWheel users as the mousewheel listeners (java.awt.etc) are now silently failing......
I kind of hope this issue will just go a away (but I'm not optimistic), so I'm starting of with this posting to my blog, instead of posting to the discussion forum which often gets swamped with homework etc.

It was always the case that library users, or anyone else for that matter who wanted to use the mouse wheel in processing had to write their own MouseWheelListener, however since the introduction of the new processing.event.Event, there was the possibility that we might be able to extend the Event class. Sadly I think there has been a decision not to support the MouseWheel (possibly in favor of the new TouchEvent?).  When I experimented in NetBeans it seemed as though we might be able to access a mouseWheelMoved method of the NEWTMouseAdapter, only to find it had not been implemented. Somewhat annoyingly but probably for good practical reasons it does not throw an unsupportedOperationException, but just silently fails. Here is the the offending line/s of code in PGL.java (r10447):-


  @Override
    public void mouseWheelMoved(com.jogamp.newt.event.MouseEvent e) {
      // Not supported in Processing.
    }

This is the sort of hack that may be required (but probably won't work either because we also need to register the native event listener in the first place).
17     @Override
18     public void mouseWheelMoved(com.jogamp.newt.event.MouseEvent e) {
19       nativeMouseEvent(e, MouseEvent.ROTATE);
20     }
....................
   1 package processing.event;
   2 
   3 public class MouseWheelEvent extends Event {
   4     int rotate = 0;
   5     public MouseWheelEvent(Object nativeObject, long millis, int action, int modifiers) {
   6         super(nativeObject, millis, action, modifiers);
   7         this.flavor = MOUSE;
   8         this.rotate += ((com.jogamp.newt.event.MouseEvent)nativeObject).getWheelRotation();
   9     }
  10     
  11     public int getRotation(){
  12         return rotate;    
  13     }
  14 }
 
Update 2 December 2012, I have proposed an enhancement to processing-2.0 to implement the mouseWheelMoved in processing-2.0 to vote for this enhancement follow this link.
Update 18 January just tried latest svn release (includes preliminary support for MouseWheel) looking good!!!!


   public void mouseEvent(MouseEvent event) {
        if (event.getAction() == MouseEvent.WHEEL) {
            System.out.println(event.getAmount());
            }
        }

Update 11 February 2013 processing development got moved to github see issue/request here:- https://github.com/processing/processing/issues/1461

1 comment:

  1. Hello, could you submit a feature request about this on the google code site (http://code.google.com/p/processing/issues/list)?
    To have more changes of seeing it implemented, have folks star it. Thanks!

    ReplyDelete

Followers

Blog Archive

About Me

My photo
Pembrokeshire, United Kingdom
I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2