Home   Help Search Login Register  

Author Topic: Dialog that cant be closed by pressing escape  (Read 1484 times)

0 Members and 1 Guest are viewing this topic.

Offline OFPWhizz

  • Members
  • *
Dialog that cant be closed by pressing escape
« on: 12 Mar 2007, 20:35:16 »
Hello.

Is there a way to set up a dialog so that the user has to press a button before it closes down (i.e they cant use escape to quit the dialog)?

Offline Cheetah

  • Former Staff
  • ****
Re: Dialog that cant be closed by pressing escape
« Reply #1 on: 12 Mar 2007, 20:49:10 »
As far as I know there is nothing to stop the player from using escape to close a dialog. What might work is using a variable to check if the player closed the dialog with the appropriate button. How to incorporate this into your script/mission?

I'll describe one way how to do this, there are much more options. Make a file called "init.sqs" and put it in the mission folder (found under your username/missions). There write the following: dialogclosed=false;

Then the only thing you need to check after opening up the dialog for the player is if he has exited the dialog, if yes, check if the variable is set to true (you can set it to true on the activation line which gets activated after a players presses a button), if not - open up the dialog again.

It has been a while since my last usage of dialogs, I'm about 95% sure that something like this will work. It's just that I don't know how everything has to be set and done. If you need more help, just ask.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Dialog that cant be closed by pressing escape
« Reply #2 on: 12 Mar 2007, 21:06:08 »
Method 1: Keep a script running in the background checking the visibility of any control present in your dialog

Code: [Select]
?(!ctrlVisible 1000): relaunch your dialog here

Method 2 (not tested): Using new displaySetEventHandler ArmA function.

First you need a handler to your dialog display, lets suppose you give 900 to your dialog idd (idd = 900;). And then you assign a script to the "KeyDown" handler.

Code: [Select]
_display = findDisplay 900
_display displaySetEventHandler ["KeyDown", "yourfunc.sqs"]

I suppose (not tested) that provided script for the "KeyDown" event gets the key pressed into its _this array, so you need to check for a 1 there. 1 = ESC.

To check the behaviour of that function you may try:
Code: [Select]
;yourfunc.sqs
hint format["KeyDown triggered, _this=%1", _this]
exit

Offline OFPWhizz

  • Members
  • *
Re: Dialog that cant be closed by pressing escape
« Reply #3 on: 12 Mar 2007, 22:16:59 »
Thanks guys thats very helpful  :)