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

Field event "missing in action"

 [1/15] from: brett:codeconscious at: 18-May-2001 13:12


Hi List, Hoping someone can help. It seems to me that the action of a field is coded to fire when edits to the field are finalised by moving off the field to another face. But it looks like a close window event is not included. Example, executing the following at a console gives a simple entry form. view layout [ f: field [alert "activated"] ] Tab key and Enter key activate the alert. But clicking on the close - window icon ie the X at the top right of the window does not activate the alert... I'm wondering how I can get it to fire. I know I can trap the close event using detect but I don't know how I can use this to solve the above problem. Why am I doing this? The obvious, set a dirty flag. I know a dirty? flag exists in fields and that one can trawl through all the entry fields to check if any are dirty, but I just want to approach it from another viewpoint - besides my application works "perfectly" except for trapping of the first change and then close window. Brett.

 [2/15] from: gjones05:mail:orion at: 18-May-2001 5:56


From: "Brett Handley"
<snip> > It seems to me that the action of a field is coded to fire
<<quoted lines omitted: 16>>
> works "perfectly" except for trapping of the first > change and then close window.
Hi, Brett, I'm not yet fully awake this morning, so my skills in articulation will likely be in even worse form than usual! However, if I recall correctly, clicking the close window icon (actually, any of the icons) on the top of the window frame is occurring in a different event space (I can't remember the official jargon) than the rest of the events detected *within* the frame. Purposeful or not, this leads to the "standard" Windows behavior (at least the Microsoft version) that clicking that icon allows for all changes to be ignored (except when the programmer has explicitly programmed in "Apply" button -type logic). It seems that this is a Windows feature/deficiency, and not a REBOL oversite. It appears that you already know (or suspect) this to be the case. Outside of a work-around methods that you were hinting about, I can only wish you the best of luck trying to intercept this event in a more elegeant way from within REBOL. A few years back, I was writing some console utilities in Delphi 2 that assisted my ISAPI interface to IIS. I don't recall the circumstances, but I do recall needing to explicitly close these windows under certain circumstances from inside other outside processes. While this might be a more trivial task in a Unix-variant, it proved to be a real challenge for me in Windows 95. My brother's work group had tried to solve a similar problem from Visual BASIC, and he said that they ultimately gave up, and switched to a totally different programming paradigm. Undaunted, I scoured the Microsoft documentation on the API's and finally got a solution only by using the lowest-level API's for spawning processes, so that I could retain hooks into those processes. Maybe this task is easier now, or maybe a "real" programmer could have done it more easily, but this was one of the most challenging tasks I ever undertook. Excuse my long-winded way of trying to encourage you to use a work-around if you need the functionality. I get the hives just thinking about the alternative. Another nice work-around might be to continuously update the word assigment from the field as each letter is typed, so that changes in the field are always trapped. Or trapping for any change in the mouse cursor captures the field data. I don't know whether the Alt-F4 can be trapped from within REBOL. Good luck, and feel free to walk to the beat of a different drummer if the mood strikes! And let me know, please, out of curiosity, if you find a simple solution. --Scott Jones

 [3/15] from: brett:codeconscious at: 18-May-2001 23:32


Hi Scott, Thanks for your reply. I'm almost asleep but hopefully my wording will be as good as yours :) You may be right with the different event space idea - but my understanding (of Windows non-console applications) is that there is one event loop that dispatches events appropriately. For Rebol this would probably dispatch key events, face events, etc to the internal Rebol event model. It has been six years since I used Delphi (1.0). More recently I've used Powerbuilder - interestingly both had similar issues relating to the problem I described - work left undone. Or perhaps the problem is with my expectations :) While I might have to use the workaround - I'd like to use the event method I described rather than the workaround polling method, because I have found in the past that I have had much better success with producing predictable user interface interactions (valid widgets according to state). Also since the event system is there, I would like to know how complete it is, how I can use it profitably and how I go about customising it. Given Borland have created a new windowing framework for the release of Kylix that will be used in Delphi as well, I'm guessing that platform independent event systems could be thorny. Still, I wait hopefully for the answer.... :) Brett.

 [4/15] from: cyphre:volny:cz at: 18-May-2001 16:10


Heya Brett ;)
> Tab key and Enter key activate the alert. But clicking on the close -
window
> icon ie the X at the top right > of the window does not activate the alert... I'm wondering how I can get
it
> to fire. > > I know I can trap the close event using detect but I don't know how I can > use this to solve the above problem. >
if I've understood your problem here is the solution: insert-event-func func [f e][if e/type = 'close [alert "don't touch this button!" return none] return e] view layout [ f: field [alert "activated"] ] have fun, Cyphre

 [5/15] from: gjones05:mail:orion at: 18-May-2001 9:38


From: "Richard Smolak"
> Heya Brett ;) > > Tab key and Enter key activate
<<quoted lines omitted: 14>>
> have fun, > Cyphre
By, George, I think he's got it! So much for my fine analysis....:-( --Scott Jones

 [6/15] from: thundrebol::yahoo at: 18-May-2001 9:22


--- Brett Handley <[brett--codeconscious--com]> wrote:
> Hi List, > Example, executing the following at a console gives > a simple entry form. > > view layout [ f: field [alert "activated"] ] >
On Windows 2000, when I run this code snippet, enter some text and click [enter], I get the following behavior: 1. The alert pop-up displays and is the active window. 2. The first time I click the "ok" button on the alert, nothing happens, even though the window is active. As the pointer moves in for the click, the mouse-over effect fires, but the button does not depress when clicked. 3. I click the button a second time. This time the button functions normally. 4. A second alert window (identical to the first) displays instantly. 5. When I click "ok" this time, I'm all clear-- no more alerts appear. If I return to the original window, type more text in the field and click [Enter], the alert dialog window functions normally, without the strange behavior. Any thoughts about what might be causing this? //Ed

 [7/15] from: kenneth:nwinet at: 18-May-2001 19:25


VB FYI,
> <snip> > >.. clicking on the close - window
<<quoted lines omitted: 9>>
> BASIC, and he said that they ultimately gave up, and switched to a > totally different programming paradigm.
Form_QueryUnload in VB fires when you click the eXit box and has a cancel parameter. Should work for <Alt><F4> also.

 [8/15] from: brett:codeconscious at: 19-May-2001 12:54


I've no idea but I noticed it as well on Win NT 4.0. It was next on my to-do list to target. What I noticed using the tab key and multiple fields is that if you make a change and hit TAB you get the behaviour you described. If you simply next time just TAB it works as expected. Make another change and TAB and you get back the wierdness. Brett.

 [9/15] from: brett:codeconscious at: 19-May-2001 13:11


Hi Cyphre, Thanks for your reply. You're close, but what I want is subtly different. Try this 1) Execute the code below. 2) Type something into the first field but don't hit tab or enter, nor click away. 3) Close the window. view layout [ style field field [disp/text: face/user-data show disp] across label "Last field:" disp: label 100 edge [size: 1x1] return below field user-data 'field-one field user-data 'field-two field user-data 'field-three do [ insert-event-func [ either event/type = 'close [ alert "Closing now. Is the last field box correct?" [quit] ][event] ] ] ] So how can I make the "Last field" box show "field-one" in this situation? Brett

 [10/15] from: gjones05:mail:orion at: 18-May-2001 23:30


From: "Brett Handley"
<snip> > Try this > > 1) Execute the code below. > 2) Type something into the first field but don't hit tab or enter, nor
click
> away. > 3) Close the window. > > view layout [ > style field field [disp/text: face/user-data show disp] > across label "Last field:" disp: label 100 edge [size: 1x1] return
below
> field user-data 'field-one > field user-data 'field-two
<<quoted lines omitted: 3>>
> either event/type = 'close [ > alert "Closing now. Is the last field box correct?"
[quit]
> ][event] > ] > ] > ] > > So how can I make the "Last field" box show "field-one" in this
situation?
> Brett
Hi, Brett,
>From Cyphre's example, might it be something like:
insert-event-func func [ f e ][ if e/type = 'close [ disp/text: copy f1/text show disp return none ] return e ] view layout [ style field field [disp/text: face/user-data show disp] across label "Last field:" disp: label 100 edge [size: 1x1] return below f1: field user-data 'field-one field user-data 'field-two field user-data 'field-three ] --Scott Jones

 [11/15] from: brett:codeconscious at: 19-May-2001 17:30


Hi Scott, I meant field-one as an example. Try it with field-three instead - you get the same problem - the box does not show field-three when the alert shows up. Putting it another way, I'm looking for some way to identify which field was being modified when the window is being closed assuming that there could be lots of fields (or other input types). It has to be there somewhere... :) Brett.

 [12/15] from: brett:codeconscious at: 19-May-2001 17:56


Found it! Well, actually the field event I originally referred to does not exist but I can effectively create my own. system/view/focal-face Set by the focus function (referred to by view*) that is in turn called by the field when the enter or tab keys are pressed. So this now works :) view layout [ style field field [disp/text: face/user-data show disp] across label "Last field:" disp: label 100 edge [size: 1x1] return below field user-data 'field-one field user-data 'field-two field user-data 'field-three do [ insert-event-func [ either event/type = 'close [ if system/view/focal-face [ disp/text: system/view/focal-face/user-data show disp alert "The box has been updated with the last focal-face." ] quit ][event] ] ] ] Thanks for the help. Brett.

 [13/15] from: gjones05:mail:orion at: 19-May-2001 7:14


From: "Brett Handley"
> Found it! Well, actually the field event I originally referred to does
not
> exist but I can effectively create my own.
Great! Now I see what you were shooting for.
> Thanks for the help.
No problem. Let's see ... for telling you it can't be done and then misundertsanding what you are looking for, I would say I was a *huge* help. You are welcome, of course. ;-) --Scott Jones

 [14/15] from: brett:codeconscious at: 20-May-2001 11:06


> > Thanks for the help. > > No problem. Let's see ... for telling you it can't be done and then > misundertsanding what you are looking for, I would say I was a *huge* > help. You are welcome, of course. ;-) > > --Scott Jones
:-)) You were a help actually. After I rechecked Cyphre's suggestion and then decided to rephrase my question to explain myself the seeds of the solution germinated. Brett.

 [15/15] from: cyphre:volny:cz at: 20-May-2001 12:19


Hello Brett,
> system/view/focal-face >
yes, that's the hit ;-) I was on a weekend trip so you were faster ;-) happy reboling... Cyphre

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted