Jump to content
Capt-Bullet

Disable ESC key while dialog open

Recommended Posts

Dialog opening begining of the mission and when we press ESC, dialog close and you can move freely .

I want to disable ESC key until dialog closed. With this way I want to prevent closing dialog without pressing dialog buttons.

Do you know solution? Thank you..

Share this post


Link to post
Share on other sites

you can deactivate the complete keyboard input.
I would not do this.
Is there a video in dialogue?
If not, you could just open the dialog again when the player presses ESC.

 

waituntil {!(IsNull (findDisplay 46))};
_keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", {
	params ["_control", "_dikCode", "_shift", "_ctrl", "_alt"];

	private _handled = false;

	switch (_dikCode) do {
		case 1: {
// case 1 for ESC -> https://community.bistudio.com/wiki/DIK_KeyCodes
// open your dialog

		};
	};

	_handled
}];

 

Share this post


Link to post
Share on other sites
3 hours ago, LoOni3r said:

you can deactivate the complete keyboard input.
I would not do this.
Is there a video in dialogue?
If not, you could just open the dialog again when the player presses ESC.

 


waituntil {!(IsNull (findDisplay 46))};
_keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", {
	params ["_control", "_dikCode", "_shift", "_ctrl", "_alt"];

	private _handled = false;

	switch (_dikCode) do {
		case 1: {
// case 1 for ESC -> https://community.bistudio.com/wiki/DIK_KeyCodes
// open your dialog

		};
	};

	_handled
}];

 

i'm trying to setup a re-spawn dialog for a vanilla mission so what i did i got one of the old epoch re-spawn and make it so i can work with vanilla but the problem is when u die or come in to the mission for first time u see the dialog and u can use it and it works no problem but if u press ESC the dialog box is no more and you can move but u are like on a spanw block i put on the middle of the water or if u die and the dialog show up u just press ESC and u are right on u body .

 

this is the menu spawn i use https://epochmod.com/forum/topic/35580-parachute-spawn-system/

 

so i move the code on spawnsystem/initspawn.sqf and put it on a onPlayerRespawn.sqf i create and all the other is the same and remove the code for the mission.sqm

Share this post


Link to post
Share on other sites

Add a keydown UIEH to your dialog:

_display displayAddEventhandler["KeyDown",{
	params ["_display","_key"];
	if (_key == 1) exitWith {true};// ESC pressed while dialog is open, overwrite default behaviour
	false
}];

Keep in mind that this will make your dialog not closeable unless you have other means to close it, like a button, at hand.

Share this post


Link to post
Share on other sites
1 hour ago, 7erra said:

_display displayAddEventhandler["KeyDown",{
    params ["_display","_key"];
    if (_key == 1) exitWith {true};// ESC pressed while dialog is open, overwrite default behaviour
    false
}];

🤔

 

_display displayAddEventhandler["KeyDown",{
	params ["", "_key"];
	_key == 1// ESC pressed while dialog is open, overwrite default behaviour
}];

💇‍♂️

Share this post


Link to post
Share on other sites
6 hours ago, Dedmen said:

_display displayAddEventhandler["KeyDown",{
	params ["", "_key"];
	_key == 1// ESC pressed while dialog is open, overwrite default behaviour
}];

 

🤔

_display displayAddEventhandler ["KeyDown", {(_this select 1) isEqualTo 1}];

💇‍♂️

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
47 minutes ago, NumbNutsJunior said:

_display displayAddEventhandler ["KeyDown", {(_this select 1) isEqualTo 1}];

 

 

🤔

disableUserInput true;

💇‍♂️

(Please don't actually use it)

  • Haha 3

Share this post


Link to post
Share on other sites
9 hours ago, 7erra said:

Add a keydown UIEH to your dialog:


_display displayAddEventhandler["KeyDown",{
	params ["_display","_key"];
	if (_key == 1) exitWith {true};// ESC pressed while dialog is open, overwrite default behaviour
	false
}];

Keep in mind that this will make your dialog not closeable unless you have other means to close it, like a button, at hand.

 

7 hours ago, Dedmen said:

🤔

 


_display displayAddEventhandler["KeyDown",{
	params ["", "_key"];
	_key == 1// ESC pressed while dialog is open, overwrite default behaviour
}];

💇‍♂️

 

1 hour ago, NumbNutsJunior said:

🤔


_display displayAddEventhandler ["KeyDown", {(_this select 1) isEqualTo 1}];

💇‍♂️

 

48 minutes ago, 7erra said:

 

🤔


disableUserInput true;

💇‍♂️

(Please don't actually use it)

Thanks guys for all the help but now i have one question with one i use and do i put it on the  onPlayerRespawn.sqf or do i put it on the dialog code it self ... i can upload like a simple mission or the code it self and again thanks all u guys for the help this is my first time doing all this

Share this post


Link to post
Share on other sites
On 2/18/2020 at 7:01 PM, Capt-Bullet said:

  Thanks guys for all the help but now i have one question with one i use and do i put it on the  onPlayerRespawn.sqf or do i put it on the dialog code it self ... i can upload like a simple mission or the code it self and again thanks all u guys for the help this is my first time doing all this

Put it whatever file the dialog is initially created with ... so once the dialog is created (createDialog), you then assign `_display = findDisplay idd` (idd is usually defined in the hpp file for the dialog).


You can use either of the first three code snippets that you quoted, dedmen just revised 7erra's snippet because it is redundant. Its like saying `_boolean = if (condition) then {true} else {false}`.

On 2/18/2020 at 9:47 AM, 7erra said:

_display displayAddEventhandler["KeyDown",{

    params ["_display","_key"];
    if (_key == 1) exitWith {true};// ESC pressed while dialog is open, overwrite default behaviour
    false
}];

 

Edit:
If you are talking about the hpp/ext file for the "dialog code", then just below where the idd is defined you will want to just add the line: 

onLoad = "(_this select 0) displayAddEventhandler ['KeyDown', {(_this select 1) isEqualTo 1}];";

... which just says "add an event handler to the dialog so that when a key is pressed, if that key is equal to 1 (escape key) then override the default behavior (closing the dialog)"

onKeyDown = "(_this select 1) isEqualTo 1";

*this should also work the same*

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
On 2/19/2020 at 1:04 PM, NumbNutsJunior said:

onLoad = "(_this select 0) displayAddEventhandler ['KeyDown', {(_this select 1) isEqualTo 1}];";

Brooooo this work like a charm thanks so much i was going crazy with this thanks guys i really appreciate

 

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×