News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.

Post Reply  Post Thread 
Escape Key exits window
Author Message
Senior Member

Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #1
RE: Escape Key exits window

This could be a very useful way to make a more friendly application.
point 1: Many people are accustomed to pressing Esc to cancel an action or close a transient window, but not so much to close a main application window. I know I was a little surprised by this behavior at the beginning.
point 2: Using an escape-ignoring function tied to the main window allows you to force another function at close, for tasks such as removing temp files, saving buffers, or simply leaving a nice goodbye message or exit confirmation.

I just tested the second point, and it seems that checking for event 12 has more use than I suspected. Apparently this allows you to call an exit function regardless of whether you create an exit button or send a close signal to the app:

function exit() print("goodbye"); os.exit(0) end

function esc_callback(myValue)
   if (Fl:event() == 12) and (Fl:event_key() == fltk.FL_Escape) then
       print ("No quit on Escape")
   else exit()
w=fltk:Fl_Window(0,0, 200, 200, "there is no escape")
quit=fltk:Fl_Button(10,10,100,30,"quit"); quit:callback(exit)

Actually, now that I think about it, I don't see how event 12 relates to my last point.
But anyway, it works =o)

This post was last modified: 06-23-2007 06:39 AM by mikshaw.

06-23-2007 06:22 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
Escape Key exits window - iGame3D - 06-21-2007, 06:39 AM
RE: Escape Key exits window - mikshaw - 06-22-2007, 07:38 AM
RE: Escape Key exits window - JohnMurga - 06-22-2007, 10:02 PM
RE: Escape Key exits window - JohnMurga - 06-23-2007, 12:29 AM
RE: Escape Key exits window - mikshaw - 06-23-2007, 01:34 AM
RE: Escape Key exits window - JohnMurga - 06-23-2007, 01:57 AM
RE: Escape Key exits window - mikshaw - 06-23-2007 06:22 AM

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: