Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Catching the Close Event

 [1/7] from: philb:upnaway at: 12-Jan-2003 10:21


Hi All, I want to catch the close event to save the position of the window when it is closed. I picked up the texchnique of inserting a global event to catch the close window event. view layout [ button "New Window" [ view/new layout [ vtext "a sub-window" red ] ] do [ insert-event-func [ either event/type = 'close [ print "Closing" event ] [event] ] ] ] But if I have more than 1 window open then how do I determine which window is being closed?? Cheers Phil

 [2/7] from: greggirwin:mindspring at: 11-Jan-2003 20:45


Hi philb, puc> I want to catch the close event to save the position of the window when puc> it is closed. puc> I picked up the texchnique of inserting a global event to catch the close puc> window event. ... puc> But if I have more than 1 window open then how do I determine puc> which window is being closed?? If you specify a block as the function you're inserting, insert-event-func will automatically convert it to a function with this signature: func [face event] So you can examine the FACE value value to see who it is. -- Gregg

 [3/7] from: gchiu:compkarori at: 12-Jan-2003 17:31


Hi Phil, This is abstracted from Gorim on the CompKarori rebsite. The basis for this code came from Cyphre. win1/data: "chatwindow" win2/data: "gomokuboard" f: func [f e][ if e/type = 'resize [ switch e/face/data [ "chatwindow" [ resize-window win1/size ] "gomokuboard" [ resize-window win2/size ] ] ] if e/type = 'close [ switch e/face/data [ "chatwindow" [ quit-prg ] "gomokuboard" [ close-board ] ] ] return e ] insert-event-func :f BTW, what happened to your chess program. Have you developed it any further? -- Regards, Graham Chiu http://www.compkarori.com/cerebrus

 [4/7] from: rotenca:telvia:it at: 12-Jan-2003 13:26


> I want to catch the close event to save the position of the window when it
is closed.
>> view/new l: layout [button] >> l/feel/detect: func [f e][all [e/type = 'close probe f/offset] e] >> do-events
281x281 --- Ciao Romano

 [5/7] from: g:santilli:tiscalinet:it at: 12-Jan-2003 14:02


Hi Phil, On Sunday, January 12, 2003, 3:21:32 AM, you wrote:
> But if I have more than 1 window open then how do I determine which window is being closed??
You can use EVENT/FACE. Or, instead of using a global event function you can use the DETECT feel of each window. Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

 [6/7] from: rotenca::telvia::it at: 12-Jan-2003 14:32


> > I want to catch the close event to save the position of the window when it > is closed. > > >> view/new l: layout [button] > >> l/feel/detect: func [f e][all [e/type = 'close probe f/offset] e] > >> do-events > 281x281
Do not forget to make the feel before changing it, else every window will share this code. The standard window-feel has code for detecting key event. If you want to preserve it, you must do something like this: view/new l: layout [button] l/feel: make l/feel [ o-d: :detect detect: func [face event][ if event/type = 'close [print face/offset] return o-d face event ] ] do-events RT suggest to use the global chain of event-func at sceen level, just to not change the standard the window-feel, i argue. --- Ciao Romano

 [7/7] from: philb:upnaway at: 13-Jan-2003 8:03


OK got this working now .... for those interested the program is now fn-close: func [f e] [ if e/type = 'close [print e/face/data] return e ] lv-lay: layout [ button "New Window" [ lv-sub-lay: layout [vtext "a sub-window" red] lv-sub-lay/data: "Sub-window" view/new lv-sub-lay ] do [insert-event-func :fn-close] ] lv-lay/data: "Main-window" view lv-lay halt Cheers Phil p.s. My chess game is still work in progress, but I havent done any development in many months ...., just too many projects to work on and not enough hours in the day. If anyone is interested in then I can post it onto my Rebsite or the developer server. Perhaps someone can inspire me to get the program finished ... or introduce network playing. === Original Message === Hi Phil, This is abstracted from Gorim on the CompKarori rebsite. The basis for this code came from Cyphre. win1/data: "chatwindow" win2/data: "gomokuboard" f: func [f e][ if e/type = 'resize [ switch e/face/data [ "chatwindow" [ resize-window win1/size ] "gomokuboard" [ resize-window win2/size ] ] ] if e/type = 'close [ switch e/face/data [ "chatwindow" [ quit-prg ] "gomokuboard" [ close-board ] ] ] return e ] insert-event-func :f BTW, what happened to your chess program. Have you developed it any further? -- Regards, Graham Chiu http://www.compkarori.com/cerebrus