Thread: middle mouse movement

Page 9 of 9 FirstFirst ... 789
Results 81 to 85 of 85
  1. #81  
    Registered Member
    Join Date
    Dec 2016
    Posts
    4
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Quote Originally Posted by znaation View Post
    how do i declare this? int type = e.getButton(); i always get an error that e isnt found

    [Only registered and activated users can see links. ]
    probably be:

    Code:
    int type = mouseevent.getButton();
    Reply With Quote  
     

  2. #82  
    Registered Member
    Join Date
    Mar 2016
    Posts
    47
    Thanks given
    1
    Thanks received
    0
    Rep Power
    11
    Quote Originally Posted by reecekrispiess View Post
    probably be:

    Code:
    int type = mouseevent.getButton();
    wont work already tried.
    Reply With Quote  
     

  3. #83  
    Forum Moderator

    Corey's Avatar
    Join Date
    Feb 2012
    Posts
    1,230
    Thanks given
    883
    Thanks received
    1,089
    Discord
    corey#2147
    Rep Power
    5000
    Quote Originally Posted by znaation View Post
    wont work already tried.
    Use an IDE.


    [Only registered and activated users can see links. ]
    Spoiler for .:

    Reply With Quote  
     

  4. #84  
    Registered Member
    Join Date
    Mar 2017
    Posts
    18
    Thanks given
    2
    Thanks received
    1
    Rep Power
    11
    When I left click, right click, or click middle mouse my camera moves. How do I fix it? Please help lol

    Here is my code:
    Code:
    	public boolean mouseWheelDown;
    
    	public final void mousePressed(MouseEvent mouseevent)
    	{
    		int i = mouseevent.getX();
    		int j = mouseevent.getY();
    		if(gameFrame != null)
    		{
    			i -= 4;
    			j -= 22;
    		}
    		idleTime = 0;
    		clickX = i;
    		clickY = j;
    		clickTime = System.currentTimeMillis();
    		int type = mouseevent.getButton();
    		if (type == 2) {
    			mouseWheelDown = true;
    			mouseWheelX = mouseevent.getX();
    			mouseWheelY = mouseevent.getY();
    			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 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 = true;
    	}
    Reply With Quote  
     

  5. #85  
    Registered Member
    Join Date
    Mar 2013
    Posts
    5
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Pretty straight forward Implementation. Worked like a charm +1 for that Cheers

    Quote Originally Posted by TheAlphaFlame View Post
    When I left click, right click, or click middle mouse my camera moves. How do I fix it? Please help lol

    Here is my code:
    Code:
    	public boolean mouseWheelDown;
    
    	public final void mousePressed(MouseEvent mouseevent)
    	{
    		int i = mouseevent.getX();
    		int j = mouseevent.getY();
    		if(gameFrame != null)
    		{
    			i -= 4;
    			j -= 22;
    		}
    		idleTime = 0;
    		clickX = i;
    		clickY = j;
    		clickTime = System.currentTimeMillis();
    		int type = mouseevent.getButton();
    		if (type == 2) {
    			mouseWheelDown = true;
    			mouseWheelX = mouseevent.getX();
    			mouseWheelY = mouseevent.getY();
    			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 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 = true;
    	}
    Comment out or completely delete mouseWheelDown = true;

    IE: //mouseWheelDown = true;
    Reply With Quote  
     

Page 9 of 9 FirstFirst ... 789

Thread Information
Users Browsing this Thread

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


User Tag List

Similar Threads

  1. Middle mouse button to move camera
    By FaintView in forum Requests
    Replies: 8
    Last Post: 05-22-2014, 12:14 AM
  2. Mouse scrolling
    By Danno in forum Tutorials
    Replies: 32
    Last Post: 05-19-2009, 07:18 AM
  3. Logical Movement
    By Meanz in forum Application Development
    Replies: 2
    Last Post: 12-08-2008, 05:34 PM
  4. Making the mouse jump around.
    By xiphias_ in forum Tutorials
    Replies: 3
    Last Post: 09-25-2008, 01:39 AM
  5. mouse trap mini not mine
    By Aggi in forum Tutorials
    Replies: 9
    Last Post: 04-09-2008, 02:38 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
  •