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

Comparing faces.

 [1/6] from: bga::bug-br::org::br at: 10-Feb-2004 15:27


So, I have this application that have 2 windows and I want to trap the 'close event on them. I am doing something like this: main-window: layout [ ... ] other-window: layout [ ... ] my-evt-func: func [ event face ] [ switch event/type [ close [ either face = WHATSHOULDIPUTHERE? [ ; Do stuff on main-window close ] [ ; Do stuff on other-window close ] ] event ] ] insert-event-function :my-evt-func view main-window The other-window is opened when the user clicks a button that is defind in the main-window layout (it is opned using view/new). So, my question is: What should I replace "WHATSHOULDIPUTHERE?" with so it will actually do what I want to do (as indicated bythe comments in the code)? I tried "face = main-window" and it did not work. -Bruno

 [2/6] from: g:santilli:tiscalinet:it at: 10-Feb-2004 17:53


Hi Bruno, On Tuesday, February 10, 2004, 6:27:30 PM, you wrote: BGA> So, my question is: What should I replace BGA> "WHATSHOULDIPUTHERE?" with so it BGA> will actually do what I want to do (as indicated bythe comments in the BGA> code)? I tried "face = main-window" and it did not work. I think you could use: in-window? main-window face Notice that some versions of REBOL have a bug in that function, but it's very easy to fix. Anyway, here's the source:
>> source in-window?
in-window?: func [ "Return true if a window contains a given face." window face][ if face = window [return true] if none? face/parent-face [return false] in-window? window face/parent-face] (Hope Carl fixes this formatting problem soon...) Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/

 [3/6] from: greggirwin:mindspring at: 10-Feb-2004 10:24


Hi Bruno, BGA> So, I have this application that have 2 windows and I want to trap the BGA> 'close event on them. I am doing something like this: I hope a real VID guru will correct me where I err, but I think FACE is always going to be the screen-face in an event function. What you want to use for comparison is EVENT/FACE. Aside from that, and a couple typos in the code you posted, you're right on track. main-window: layout [bt: button [view/new other-window]] other-window: layout [button "x"] my-evt-func: func [face event] [ switch event/type [ close [ either event/face = main-window [ print "closing main window" ] [ print "closing other window" ] ] ] event ] insert-event-func :my-evt-func view main-window -- Gregg

 [4/6] from: bga:bug-br at: 10-Feb-2004 16:24


Hello Gabriele. Thanks for your answer. I tried it and it did not work. I added a "probe in-window? main-window face" as the first line on my-event-func so it is executed for any event that happens. Even with only the main-window opened that probe is resulting in "false". I am puzzled. -Bruno Gabriele Santilli disse:

 [5/6] from: gchiu:compkarori at: 11-Feb-2004 1:16


Bruno G. Albuquerque wrote.. apparently on 10-Feb-2004/15:27:30-2:00
>So, I have this application that have 2 windows and I want to trap the >'close event on them. I am doing something like this: > >main-window: layout [ ... ] >other-window: layout [ ... ]
I haven't done this stuff for a while, but looking at my old code, I found this if e/type = 'close [ switch e/face/data [ "chatwindow" [ quit-prg ] "gomokuboard" [ do-something-else] ] -- Graham Chiu http://www.compkarori.com/cerebrus

 [6/6] from: g:santilli:tiscalinet:it at: 11-Feb-2004 12:20


Hi Gregg, On Tuesday, February 10, 2004, 6:24:20 PM, you wrote: GI> I hope a real VID guru will correct me where I err, but I think FACE GI> is always going to be the screen-face in an event function. Ah, right, because that's in the DETECT of the screen face. (I confess I never use INSERT-EVENT-FUNC, I have my own window feel replacing the standard one that has a few more features, one of which is calling window/action if defined on close etc.) Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/