From 9adf1a6d05251ea62e8303ad318934896e2d3656 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 12 Dec 2019 00:42:22 +0000 Subject: [PATCH] Converted JavaScript remote closing to use jQuery --- nui/radar.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/nui/radar.js b/nui/radar.js index 99f6078..8f40dda 100644 --- a/nui/radar.js +++ b/nui/radar.js @@ -382,23 +382,24 @@ elements.remote.find( "button" ).each( function( i, obj ) { } ); // Close the remote when the user presses the 'Escape' key or the right mouse button -document.onkeyup = function( event ) +function closeRemote() { - if ( event.keyCode == 27 ) - { - sendData( "closeRemote", null ); - setRemoteVisible( false ); - setUISettingsVisible( false, false ); - } -} - -window.oncontextmenu = function() -{ - sendData( "closeRemote", null ); + sendData( "closeRemote", null ); setRemoteVisible( false ); setUISettingsVisible( false, false ); } +$( document ).keyup( function( event ) { + if ( event.keyCode == 27 ) + { + closeRemote(); + } +} ); + +$( document ).contextmenu( function() { + closeRemote(); +} ); + // The main event listener, this is what the NUI messages sent by the LUA side arrive at, they are // then handled properly via a switch/case that runs the relevant code window.addEventListener( "message", function( event ) {