Thread: Fix mouse clicking in java 9

Page 1 of 8 123 ... LastLast
Results 1 to 10 of 71
  1. #1 Fix mouse clicking in java 9 
    Super Donator

    StanDev's Avatar
    Join Date
    Apr 2014
    Posts
    660
    Thanks given
    82
    Thanks received
    255
    Rep Power
    592
    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  
    Banned
    Join Date
    Sep 2017
    Posts
    159
    Thanks given
    13
    Thanks received
    11
    Rep Power
    0
    thanks very much needed this
    Reply With Quote  
     

  3. #3  
    Respected Member


    Join Date
    Jan 2009
    Posts
    5,743
    Thanks given
    1,162
    Thanks received
    3,603
    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  
    Super Donator

    StanDev's Avatar
    Join Date
    Apr 2014
    Posts
    660
    Thanks given
    82
    Thanks received
    255
    Rep Power
    592
    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

    LionLF's Avatar
    Join Date
    Aug 2017
    Posts
    234
    Thanks given
    76
    Thanks received
    76
    Rep Power
    115
    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  
    Renown Programmer
    Bartvh's Avatar
    Join Date
    May 2017
    Posts
    370
    Thanks given
    89
    Thanks received
    208
    Rep Power
    497
    Rune-server community be like:
    Attached image

    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,084
    Thanks given
    0
    Thanks received
    1,043
    Rep Power
    3608
    Quote Originally Posted by Bartvh View Post
    Rune-server community be like:
    Attached image

    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 & Respected Member

    Ryley's Avatar
    Join Date
    Aug 2011
    Posts
    596
    Thanks given
    254
    Thanks received
    521
    Rep Power
    1332
    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  
    Extreme Donator


    Join Date
    Oct 2010
    Posts
    2,853
    Thanks given
    1,213
    Thanks received
    1,622
    Rep Power
    5000
    Awesome, thanks
    Reply With Quote  
     

  10. #10  
    Im an albatraoz

    Nand0's Avatar
    Join Date
    Feb 2010
    Age
    31
    Posts
    948
    Thanks given
    233
    Thanks received
    128
    Rep Power
    241
    Thank you!



    Looking for blazing fast and affordable vps or web hosting?
    AllGeniusHost



    Reply With Quote  
     

Page 1 of 8 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 Zach 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
  •