Notifications
Clear all

[Closed] Close dialog when ESC is pressed

I’m making a dialog in Max script but can’t find out how to make it close when ESC key is pressed. Here’s my code:


 try(DestroyDialog Save_File)catch()
  Rollout Save_File "Save Scene"
  (
  	button btn_save "Save?" width:100 height:50
  	on btn_save pressed do 
  	(
  		actionMan.executeAction 0 "40006"  -- File: Save File
  		Destroydialog Save_File
  	) 
  )
  CreateDialog Save_File
  
4 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

closing by Esc makes sense only for modal dialog (or a dialog that holds focus at least).

undo off
(
global temp_box = Box width:1 length:1 height:1
hide temp_box
)
try(DestroyDialog Save_File)catch()
Rollout Save_File "Save Scene"
(
button btn_save "Save?" width:100 height:50
timer clock "testClock" interval:10
on Save_File close do
(delete temp_box)
on btn_save pressed do 
(
actionMan.executeAction 0 "40006"
Destroydialog Save_File
) 
on clock tick do
(try (if keyboard.escPressed == true do delete temp_box) catch())
)
CreateDialog Save_File
when temp_box deleted do destroydialog Save_File

Easy to use ZETEXCEL – THE FASTEST EXCEL SDK FOR .NET APPLICATIONS. Ability to save & load Excel files to & from streams.

WTF? and what does it do on this forum?

and in general, those who litter the forum, it is necessary for the first time to give a warning at a discount for their stupidity, and then just ban