newLISP Fan Club

Forum => newLISP Graphics & Sound => Topic started by: newdep on November 12, 2007, 07:19:54 AM

Title: gs:check-event adujstment for user defined exit.
Post by: newdep on November 12, 2007, 07:19:54 AM
Hi Lutz,



A current problem with the gs:check-event is that it will (exit) when the user

presses the 'EXIT button on the Window or if the event is 'NIL.



Actualy what you want is an exit of the guiserver but NOT from the newlisp script.



Currently open files and running processes/forks cant be catched

when the user closed the window.



I tried to adjust this in guiserver.lsp but the guiserver.jar keeps hanging now ;-)



Norman.
Title:
Post by: Lutz on November 12, 2007, 12:09:20 PM
You could use gs:window-closed to fire an event in newLISP. This event handler than could shut down in an orderly fashion and then simply exit, which then will let the guiserver shut down too:


#!/usr/bin/newlisp
; close-demo.lsp - demonstrate window-closed event

(load (append (env "NEWLISPDIR") "/guiserver.lsp"))

(gs:init)

(gs:frame 'CloseDemo 100 100 400 300 "Close window demo")
(gs:window-closed 'CloseDemo 'closing-action)
(gs:set-resizable 'CloseDemo nil)
(gs:set-visible 'CloseDemo true)

(define (closing-action)
(println (args))
(println "Cleaning up")
(sleep 2000)
(exit)
)

(gs:listen)
;; eof


Lutz
Title:
Post by: newdep on November 12, 2007, 12:16:30 PM
Thanks  window-closed  did the trick ! ;-)