Jump to content

Photo
- - - - -

Prevent Esc key closing dialog


  • Please log in to reply
11 replies to this topic
dr_eyeball
dr_eyeball

    Master Sergeant

  • Members
  • 604 posts

#1

Posted 16 August 2007 - 03:09

Looking for advice on how to prevent the Escape key from closing a dialog.

Possible solutions: I'm guessing it would somehow be done via User_Interface_Event_Handlers, which are easy enough, but I still don't know how to prevent the closure.
Perhaps it's controlled via a return value in one of the functions or EH's?

Situation: After having no success from this child dialogs discussion, I have resorted to combining 2 dialogs into 1. I have nested a popup menu dialog into another commander dialog and the instinct is to press Esc to close the menu, but that will close the commander dialog too. Instead I want to close dialogs only via a ["X"] close icon in the window/menu title bar (or some other controlled manner).

Example: Screenshot
Posted Image

Long discussion for a simple question...
Posted Image

T_D
T_D

    CWR² Developer

  • Members
  • 552 posts

#2

Posted 16 August 2007 - 03:26

You cant avoid the dialog being closed if Esc was pressed I would say. But you can re-create the dialog as soon as the dialog was closed and the user wont notice that. You should use the onUnload eventhandler to save the current selected item in the listbox and to start the dialog again.

Zaphod
Zaphod

    Staff Sergeant

  • Members
  • 293 posts

#3

Posted 21 August 2007 - 14:52

i use a simple spawned loop, checking for dialog=true...

as become false, it will throw a "Don't ESC Dialog" Message and fire the startdialog-function again...

as you use a framework, hmmm ... the only way i can suggest is that your framework keeps current state in a global variable, and needs a capability to restore settings from it ... so on close you can restore last saved settings & lbcursel and focuses ...

kind of additional work, but offers a good debugging capability, too.

Regards,
zap

benreeper
benreeper

    Master Sergeant

  • Members
  • 614 posts

#4

Posted 22 August 2007 - 02:11

disableuserinput
--Ben

ricki
ricki

    Sergeant

  • Members
  • 123 posts

#5

Posted 22 August 2007 - 04:31

disableUserInput will block mouseclicks, too.

Zaphod
Zaphod

    Staff Sergeant

  • Members
  • 293 posts

#6

Posted 24 August 2007 - 14:24

yes ... disableuserinput won't do it ..

it's kind of tricky in this case.

CrashDome
CrashDome

    Master Gunnery Sergeant

  • Members
  • 1260 posts

#7

Posted 24 August 2007 - 16:18

Disabling the ESC key would suck for a player. How am I supposed to exit the game should I want to? I wouldn't use ANY dialog that didn't let me ESC.

Why do you need to disable it? So you can force them to click many X's? If ESC closes everything, I say let the player learn the hard way NOT to hit ESC if they don't mean to.





dr_eyeball
dr_eyeball

    Master Sergeant

  • Members
  • 604 posts

#8

Posted 25 August 2007 - 01:16

Disabling the ESC key would suck for a player. How am I supposed to exit the game should I want to? I wouldn't use ANY dialog that didn't let me ESC.

Why do you need to disable it? So you can force them to click many X's? If ESC closes everything, I say let the player learn the hard way NOT to hit ESC if they don't mean to.

Read the entire first post, before replying. Nobody is trying to disable Esc key solely for the purpose of preventing closing dialogs.

When 2 dialogs are nested into 1, you sometimes want to detect that Esc has been pressed in order to close your sub-dialog and leave the pseudo parent dialog open. Is that so unreasonable? You then press Esc again to close the pseudo parent dialog.
Posted Image

Zaphod
Zaphod

    Staff Sergeant

  • Members
  • 293 posts

#9

Posted 25 August 2007 - 04:45

agree with dr. eyeball ... esc will you lead through opened dialog layers until you reach the arma hardcoded layer... the simple esc~respawn dialogue...

the whatabout is, what happenz as the "map-engine" dialog was escaped ... that means current dialog 0 (+x)

@Eyeball ... did you find a solution??
@CrashDome ... howto create rounded corners Posted Image

regards,
zap





benreeper
benreeper

    Master Sergeant

  • Members
  • 614 posts

#10

Posted 26 August 2007 - 05:30

Why not make the pop-up dialogue part of the main dialogue and use ctrlshow to pop it up when you need it.
--Ben

CrashDome
CrashDome

    Master Gunnery Sergeant

  • Members
  • 1260 posts

#11

Posted 27 August 2007 - 03:20

Read the entire first post, before replying. Nobody is trying to disable Esc key solely for the purpose of preventing closing dialogs.

um....

Quote[/b] ]Looking for advice on how to prevent the Escape key from closing a dialog.


Posted Image

Sorry, but those phrases looked like exact opposites to me.

Either way, I still stand by my advice that the ability to alter the effects of ESC key is contradictory to the purpose and behavior it was intended for. You can program any other key ('X' perhaps?) to close a child dialog. Why *must* it be ESC?

The_Captain
The_Captain

    Gunnery Sergeant

  • Members
  • 427 posts

#12

Posted 30 July 2008 - 03:59

Total thread necromancy, but as far as I know you can override any arma key input by detecting the keypress with a displayeventhandler and simply returning *true* as the function's return value. Thanks to Spooner for demonstrating how to do that. Posted Image

http://community.bis...SetEventHandler

I'm using this trick to prevent esc from closing the child dialog and the main one; it'll only close the child if you're in the child, and the main if you're in the main.

I haven't tested this just yet, but it should work. I'll repost if it somehow fails...

Hopefully this tip will help someone out who needs it. Posted Image




AI Grenadier Aiming Fix
Close Assault: Company level team vs. team game mode for 32 players.