[HELP] Preventing mouse wheel [ANSWERED]

Discussion in 'Mod Discussions' started by Raevn, August 19, 2013.

  1. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,324
    I'm trying to add an area of the UI to display something with scrolling, but while scrolling with the mousewheel, the main window zooms too. I've tried various methods to prevent the main window from also zooming (.addEventListener, .bind, onmousewheel, mousewheel, and pretty much anything I could google), but none of them are working.

    My current attempt is as follows. The debugger does not show any errors.
    Code:
    $("#test_div").bind('mousewheel', function(e, d) {e.preventDefault();});
    Anyone tried/know how to do this?
  2. oxide246

    oxide246 Active Member

    Messages:
    249
    Likes Received:
    30
    I'm pretty sure the zooming is currently done in the engine and not though a javascript mouse bind? Although I'll double check this later. I think I've seen an engine call to disable and re-enable key actions, this might do it. Again I'll report back if you haven't found it already by the time I do.
  3. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    yeah also when sending messages, moving up down left and right through the text you're typing will make the planet move. it's silly.
  4. oxide246

    oxide246 Active Member

    Messages:
    249
    Likes Received:
    30
    I found this in shared/js/console.js

    Code:
    api.game.captureKeyboard();
    api.game.releaseKeyboard();
    This seems to do the trick for the mouse wheel which is what you need, but not for the left and right keys like tatsujb says... which is a bit strange.
  5. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
  6. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,324
    This worked, thanks! Although why captureKeyboard prevents the mousewheel, I have no idea.
  7. masterdigital

    masterdigital Uber Alumni

    Messages:
    438
    Likes Received:
    833
    The arrow keys are one of the last things that need to move into JS. Kevin was working on this but has been distracted by perf issues.

Share This Page