Thread: Fix mouse clicking in java 9

Page 1 of 5 123 ... LastLast
Results 1 to 10 of 48
  1. #1 Fix mouse clicking in java 9 
    Donator

    StanDev's Avatar
    Join Date
    Apr 2014
    Posts
    657
    Thanks given
    70
    Thanks received
    231
    Rep Power
    526
    Java 9 introduced a few bugs in the ancient client engine most people use, the most noticeable one is right mouse clicking.

    Go to the class where you handle your mouse clicking, usually in RSApplet.java.

    Search for this:
    Code:
     
    if (type == 2) {
    			mouseWheelDown = true;
    			mouseWheelX = i;
    			mouseWheelY = j;
    			return;
    		}
    replace the if statement with:
    Code:
    if (SwingUtilities.isMiddleMouseButton(e)) {
    Note that the argument of the method (e) is the MouseEvent object reference, this might be named differently in your client.

    Then search for:
    Code:
    		if (mouseevent.isMetaDown()) {
    			clickMode1 = 2;
    			clickMode2 = 2;
    		}
    Replace the first if statement with:
    Code:
    	if(SwingUtilities.isRightMouseButton(e)) {
    Then also in the following else block:
    Code:
    	} else {
    			clickMode1 = 1;
    			clickMode2 = 1;
    		}
    replace the else line with:
    Code:
    	} else if(SwingUtilities.isLeftMouseButton(e)){
    As pointed out by Jire, it is better to do it this way:
    Quote Originally Posted by Jire View Post
    An issue with using the isRightMouseButton static method is that it includes a check for the down mask of the button, which means it will return true so long as the right mouse button is down.
    Code:
    /**
     * Returns true if the mouse event specifies the right mouse button.
     *
     * @param anEvent  a MouseEvent object
     * @return true if the right mouse button was active
     */
    public static boolean isRightMouseButton(MouseEvent anEvent) {
        return ((anEvent.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK);
    }
    This introduces a problem because players will not be able to hold right click and then left click without letting go of right click, which is a common habit for many people, especially those familiar with Mac and certain GNU/Linux desktop environments.

    Instead, you should check if the event's button (event.getButton()) equals the constants from MouseEvent, i.e.:
    Code:
    event.getButton() == MouseEvent.BUTTON3
    This will properly support all Java versions, per the AWT event contract.
    Last edited by StanDev; 08-25-2019 at 10:41 PM.
    Reply With Quote  
     


  2. #2  
    Registered Member
    Join Date
    Sep 2017
    Posts
    141
    Thanks given
    13
    Thanks received
    9
    Rep Power
    42
    thanks very much needed this
    Reply With Quote  
     

  3. #3  
    Appellate Moderator



    Join Date
    Jan 2009
    Posts
    5,650
    Thanks given
    1,067
    Thanks received
    3,361
    Rep Power
    5000
    shouldnt really be using java 9 yet, majority of people still using 1.6 even. better to be compatible with the majority of systems then force them to update, unless you ship jre with your build.
    Reply With Quote  
     

  4. #4  
    Donator

    StanDev's Avatar
    Join Date
    Apr 2014
    Posts
    657
    Thanks given
    70
    Thanks received
    231
    Rep Power
    526
    Quote Originally Posted by Stuart View Post
    shouldnt really be using java 9 yet, majority of people still using 1.6 even. better to be compatible with the majority of systems then force them to update, unless you ship jre with your build.
    In my own server, the majority of people have (unknowingly) upgraded to Java 9. Also, judging from the Javadoc the SwingUtilities class is already present in java 6.
    This only fixes the compatibility of your client with Java 9, it doesn't force you to upgrade to it.
    Reply With Quote  
     

  5. #5  
    Donator

    zukke's Avatar
    Join Date
    Aug 2017
    Posts
    234
    Thanks given
    76
    Thanks received
    75
    Rep Power
    90
    Quote Originally Posted by Stuart View Post
    shouldnt really be using java 9 yet, majority of people still using 1.6 even. better to be compatible with the majority of systems then force them to update, unless you ship jre with your build.
    well it actually helps a lot, otherwise you have tell your players to downgrade java, which may cause a lot of headaches lol. (i personally had maybe total 20 people who used to update java all the time they got message lmao).
    Reply With Quote  
     

  6. #6  
    Registered Member
    Bartvh's Avatar
    Join Date
    May 2017
    Posts
    317
    Thanks given
    68
    Thanks received
    114
    Rep Power
    147
    Rune-server community be like:


    Anyway, gj OP won't use it myself but a lot of people propably needed this.
    Reply With Quote  
     

  7. #7  
    Registered Member

    Join Date
    Oct 2011
    Posts
    2,091
    Thanks given
    0
    Thanks received
    1,017
    Rep Power
    3443
    Quote Originally Posted by Bartvh View Post
    Rune-server community be like:


    Anyway, gj OP won't use it myself but a lot of people propably needed this.
    perhaps that's what they mean when they advertise as "oldschool".

    ot: thanks for sharing.
    Reply With Quote  
     

  8. #8  
    Renown Programmer
    Ryley's Avatar
    Join Date
    Aug 2011
    Posts
    595
    Thanks given
    250
    Thanks received
    485
    Rep Power
    1173
    Yeah have noticed this in my server as well (1 in every 30 people or so had the problem), was quite annoying as I was unable to diagnose the issue. I wasn't even aware that Java 9 was available for GA yet. Thanks OP lad for digging deeper and figuring this out.
    Reply With Quote  
     

  9. #9  
    Rune-Server Affiliate

    Join Date
    Oct 2010
    Posts
    2,846
    Thanks given
    1,192
    Thanks received
    1,590
    Rep Power
    5000
    Awesome, thanks
    Reply With Quote  
     

  10. #10  
    Im an albatraoz
    Nand0's Avatar
    Join Date
    Feb 2010
    Age
    27
    Posts
    763
    Thanks given
    160
    Thanks received
    108
    Rep Power
    71
    Thank you!
    Reply With Quote  
     

Page 1 of 5 123 ... LastLast

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. [667/7**] How to fix right click bug in PvP
    By ZachTX in forum Tutorials
    Replies: 5
    Last Post: 06-30-2014, 05:06 PM
  2. Fix another bug in pickuping! + Video
    By Pkitten in forum Tutorials
    Replies: 59
    Last Post: 05-27-2008, 12:17 PM
  3. PKScapeX is recruiting a MySQL in Java developer
    By Stanyer in forum RS2 Server
    Replies: 7
    Last Post: 01-09-2008, 02:22 AM
  4. How to Make objects give you in item when you click in them!
    By black-pure-4-lyfe in forum Tutorials
    Replies: 3
    Last Post: 08-28-2007, 09:35 AM
  5. Fixing Logout Glitch in WhiteScape
    By Santa Noobie in forum Tutorials
    Replies: 2
    Last Post: 05-29-2007, 10:58 PM
Tags for this Thread

View Tag Cloud

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •