Thread: Mouse Wheel Scrolling Issue

Results 1 to 2 of 2
  1. #1 Mouse Wheel Scrolling Issue 
    Registered Member
    Join Date
    Apr 2014
    Posts
    2
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    &*&*&*&*&* ONE MORE FINAL UPDATE *&*&*&*&*&*

    Got it all working, except it activates with the right mouse button instead of the mouse wheel. Any ideas?

    Full Code

    Code:
    	public boolean mouseWheelDown;
    	public final void mousePressed(MouseEvent mouseevent)
    	{
    		int i = mouseevent.getX();
    		int j = mouseevent.getY();
    		if(gameFrame != null)
    		{
    			i -= 4;//4
    			j -= 22;//22
    		}
    		idleTime = 0;
    		clickX = i;
    		clickY = j;
    		clickTime = System.currentTimeMillis();
    		if (mouseevent.isMetaDown()) {	
    			mouseWheelDown = true;
    			mouseWheelX = mouseX;
    			mouseWheelY = mouseY;
    			return;
    		}
    		if(mouseevent.isMetaDown())
    		{
    			clickMode1 = 2;
    			clickMode2 = 2;
    		} else
    		{
    			clickMode1 = 1;
    			clickMode2 = 1;
    		}
    	}
    
    	public final void mouseReleased(MouseEvent mouseevent)
    	{
    		idleTime = 0;
    		clickMode2 = 0;
    		mouseWheelDown = false;
    	}
    
    	public final void mouseClicked(MouseEvent mouseevent)
    	{
    	}
    
    	public final void mouseEntered(MouseEvent mouseevent)
    	{
    	}
    
    	public final void mouseExited(MouseEvent mouseevent)
    	{
    		idleTime = 0;
    		mouseX = -1;
    		mouseY = -1;
    	}
    	public int mouseWheelX;
    	public int mouseWheelY;
    	public final void mouseDragged(MouseEvent e) {
    		int x = e.getX();
    		int y = e.getY();
    		if(gameFrame != null) {
    			Insets insets = gameFrame.getInsets();
    			x -= insets.left;//4
    			y -= insets.top;//22
    		}
    		if (mouseWheelDown) {
    			y = mouseWheelX - e.getX();
    			int k = mouseWheelY - e.getY();
    			mouseWheelDragged(y, -k);
    			mouseWheelX = e.getX();
    			mouseWheelY = e.getY();
    			return;
    		}
    		idleTime = 0;
    		mouseX = x;
    		mouseY = y;
    		mouseWheelDown = false;
    	}
    	void mouseWheelDragged(int param1, int param2) {
    	}
    Reply With Quote  
     

  2. #2  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    941
    Thanks given
    46
    Thanks received
    146
    Rep Power
    354
    I think you need to compare the .getButton() function from the MouseEvent with "MouseEvent.BUTTON_2" (which should be the mouseWheel button).
    The isMetaDown refers to the "meta"/"modifier" key on your keyboard (if you have any) I think. For even more complexity you can use the "getModifiersEx()" function from the MouseEvent [Only registered and activated users can see links. ].

    Alternatively you can use: SwingUtilities.isMiddleMouseButton(MouseEvent anEvent) to check if the mouseEvent is triggered by the mouseWheel button.
    My informative threads:
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. mouse wheel movement issue
    By znaation in forum Help
    Replies: 0
    Last Post: 10-04-2017, 09:17 AM
  2. Disable mouse wheel scrolling
    By Enyll in forum Help
    Replies: 2
    Last Post: 05-29-2017, 06:21 PM
  3. [RS317 Lite(can be adapted easily)] [Ren] Mouse-Wheel scrolling
    By Thee Interface Guy in forum Snippets
    Replies: 4
    Last Post: 07-13-2012, 04:36 AM
  4. [PI]Mouse Wheel Scrolling in Bank + Chat??
    By addicted in forum Help
    Replies: 4
    Last Post: 03-14-2011, 09:06 AM
  5. Working Mouse wheel!!
    By SWAT in forum Show-off
    Replies: 27
    Last Post: 05-12-2009, 12:11 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •