Vid / Subpanels / Dirty?
[1/11] from: sanghabum:aol at: 31-May-2001 8:43
Can someone help me out here? The Dirty? flag doesn't seem to get set when using subpanels. Take the script at the end of this email, for example, which is the Rebol How-to on Subpanels with these two lines changed to name fields mydata1: field "Field 1" mydata2: field "Field 2" Fire up the code, overtype the text in Field1 and Field2, close the window (Not with the Quit button!), and then check the values: mydata1/text - should be what you changed it to; but mydata1/dirty? - always comes up as None for me. Am I (as I often do) missing the point? I've tried researching Dirty? but there's not a single script in the library that uses it. Thanks for any clarification. I'm on View 1.2 under Win 98, --Colin =====Subpanel script===== REBOL [Title: "Subpanels"] main: layout [ vh2 "Subpanel Examples" guide pad 20 button "Panel 1" [panels/pane: panel1 show panels] button "Panel 2" [panels/pane: panel2 show panels] button "Quit" [Quit] return box 2x140 maroon return panels: box 220x140 ] panel1: layout [ origin 8x8 h2 "Panel 1" mydata1: field "Field 1" mydata2: field "Field 2" button "The Answer" [alert "I know nothing."] ] panel2: layout [ origin 8x8 h2 "Panel 2" across txt "X:" slider 150x16 return txt "Y:" slider 150x16 return check [panel2/color: maroon show panel2] txt "Don't click this" return check [panel2/color: silver show panel2] txt "Click this" return ] panel1/offset: 0x0 panel2/offset: 0x0 panels/pane: panel1 view main ===== script end =====
[2/11] from: gjones05:mail:orion at: 31-May-2001 8:39
> Can someone help me out here? > > The Dirty? flag doesn't seem to get set when using subpanels. Take the
> at the end of this email, for example, which is the Rebol How-to on
> with these two lines changed to name fields > > mydata1: field "Field 1" > mydata2: field "Field 2" > > Fire up the code, overtype the text in Field1 and Field2, close the
> (Not with the Quit button!), and then check the values: > > mydata1/text - should be what you changed it to; but > mydata1/dirty? - always comes up as None for me. > > Am I (as I often do) missing the point? I've tried researching Dirty?
> there's not a single script in the library that uses it. > > Thanks for any clarification. I'm on View 1.2 under Win 98,
Hi, Colin, We normally try not to talk "dirty?" on the list. ;-) Here is an extension that more graphically show some of what is going on: update-text: does [ mytext1/text: rejoin [mydata1/text " " mydata1/dirty?] mytext2/text: rejoin [mydata2/text " " mydata2/dirty?] show [mytext1 mytext2] ] lo: layout [ mydata1: field "Field 1" [update-text] mytext1: txt 100 mydata2: field "Field 2" [update-text] mytext2: txt 100 do [update-text] ] view lo So, it appears as though your assumption about dirty? changing to true on a change is correct (did that make sense??). You will notice that pressing return and tab leave the dirty? flag in a different state in the other faces than when you use the mouse to click. Hope this illucidates the dirty? -talk phenomenon. --Scott Jones
[3/11] from: sanghabum:aol at: 31-May-2001 14:52
> Hi, Colin, > We normally try not to talk "dirty?" on the list.
<<quoted lines omitted: 6>>> pressing return and tab leave the dirty? flag in a different state in > the other faces than when you use the mouse to click.
Okay! I got it! "Dirty?" is reset whenever the field is reshown. that's enough of a clue for me to code my own persistent-dirty? flag-----I need that because the thingie I'm writing wants to know which fields have changed across several subpanels when the user presses the "update button". We may not talk "dirty?" often, but I think it was the late John Sladek who pointed out just how smutty most computer language is. He instanced bits, bytes and rams if I remember rightly. Here's a short poem written entirely from words found in Vid 1.2 system/words: View-face Open wrap Feel top Probe bottom Show-popup [I'll excise the second verse--which starts "bump"--on the grounds of good taste] Thanks again, --Colin.
[4/11] from: gjones05:mail:orion at: 31-May-2001 14:31
> Here's a short poem written entirely > from words found in Vid 1.2 system/words:
<<quoted lines omitted: 3>>> Probe bottom > Show-popup
This is truly inspired! Ahem. As far as collecting changed fields for an update, you may wish to peruse a thread from a few weeks ago. Although Brett's end purpose was slightly different, in the end, he created a nifty way to collect changed data and to capture for an inadvertantly closed dialog. You may find some of this quite useful in order to save users from themselves (namely, offer them a final chance to update or cancel the changes). Just a thought. The full thread URL of course needs to be recontructed without line breaks. http://www.escribe.com/internet/rebol/index.html?by=OneThread&t=%5BREBOL %5D Field event %22missing in action%22 His solution is found here: http://www.escribe.com/internet/rebol/m9067.html --Scott Jones
[5/11] from: sanghabum::aol::com at: 31-May-2001 17:31
> As far as collecting changed fields for an update, you may wish to > peruse a thread from a few weeks ago. Although Brett's end purpose was
<<quoted lines omitted: 3>>> (namely, offer them a final chance to update or cancel the changes). > Just a thought.
Thanks again. I've solved the problem by adding an action to each data entry field. A (simplified) snippet of the code that build the layout reads: DataEntryFields: copy ["Name" "Age" "Favorite Poem"] foreach def DataEntryFields [ append layoutBlock to-word join "Data-" [Def ": "] append layoutBlock [Field] append layoutBlock [[Persistent-Dirty?: true]] Return ] So 'persistent-dirty? (a global variable) is set true if any field is changed. And then I can iterate around the DataEntryFields block to find the new values. What I can't do is tell which of the individual fields has changed, but I don't need that: any change will trigger the update processing. Incidentally, I don't recommend building a layout with variables directly into a block as the above example does. Returning the block from a function and then issuing the 'Layout command taught me rather more about context than I really wanted to know at the time. Code I've written today (as opposed to yesterday) builds dynamic layouts in strings. Stick a square bracket at each end and a simple 'Load will turn that into a block when needed without moaning about undefined variables. Thanks again, --Colin.
[6/11] from: brett:codeconscious at: 1-Jun-2001 15:08
Hi Colin, Reading you post literally I think you may have the same problem I encountered and that Scott referred to. Try this test in you application to check: 1) Start a fresh version of you application. 2) Type something into a field but WITHOUT hitting TAB or ENTER, nor clicking anywhere else. 3) Close the window. 4) Does you application correctly trap the dirty state? If not, here is an example of something equivalent to the solution I'm using at present. dirty-flag: false ready-to-continue?: function [/nocancel] [is-ready save-it] [ either dirty-flag [ if save-it: either nocancel [ request/confirm "Save changes now?" ][ request "Save changes before continuing?" ] [ alert "Save data now - stub" ] is-ready: not none? save-it ][ is-ready: true ] RETURN is-ready ] view layout [ test-field: field [dirty-flag: true] do [ insert-event-func [ either event/type = 'close [ last-face: system/view/focal-face if all [ last-face not none? get in last-face 'action] [ last-face/action last-face last-face/data ] if ready-to-continue? [quit] ][event] ] ] ] I'm interested though if others have a better solution. In particular I'm unsure of if I should use insert-event-func or code a detect function. Probably ends up the same. Regards, Brett
[7/11] from: petr:krenzelok:trz:cz at: 1-Jun-2001 8:46
'lo Brett :-) Brett Handley wrote:
> view layout [ > test-field: field [dirty-flag: true]
<<quoted lines omitted: 13>>> unsure of if I should use insert-event-func or code a detect function. > Probably ends up the same.
Not all the same. There is slight difference. Detect function is defined in face level, so it means you would have to code your detect for all your windows (faces) separately ... while insert-event-func imo inserts your function directly at the top of the tree, so events coming from all faces are checked thru your function. This way is usefull for debugging imo, as without a change of app you can "install" event checking functions and monitor what is happening ... -pekr-
[8/11] from: brett:codeconscious at: 1-Jun-2001 22:05
Thanks Pekr. A subtle and useful difference - I'll need to experiment more. Brett.
[9/11] from: sanghabum:aol at: 1-Jun-2001 9:21
> Reading you post literally I think you may have the same problem I > encountered and that Scott referred to.
<<quoted lines omitted: 5>>> 4) Does you application correctly trap the dirty state? > If not, here is an example of something equivalent to the solution I'm
> at present. <snip>
No it doesn't trap it. I think this is different to my original problem which was one of perception.....I'd read "Dirty?" as meaning "changed from time of 'Layout". But it means "Changed since last 'Show". I haven't delved as far as 'insert-event-func yet, but I am going to want to trap my user's clicking the close icon, or ctrl-F4'ing, so thanks for the code example. --Colin
[10/11] from: brett:codeconscious at: 2-Jun-2001 23:58
Hi Scott, Thought I'd send this to you privately because I didn't feel I should announce such an incremental change on the list but given your interest in learning all things Rebol/View moment I thought you'd might find it useful one day. :) Basically, I've developed my thinking just a tad more on the "Dirty" problem when closing windows. I decided that there were two seperate issues involved: ensuring the appliation dirty flag is set when closing a window, and trapping the close window event. Described wordily here: do http://www.codeconscious.com/rebsite/vid-notes.r Regards, Brett.
[11/11] from: brett:codeconscious at: 3-Jun-2001 0:21
My visual response on reading last message I posted inadvertently on this thread: view layout [ box 300x300 white effect [ draw [ pen black fill-pen red circle 150x150 120 fill-pen white red circle 110x120 40 red circle 190x120 40 fill-pen black circle 110x120 5 red circle 190x120 5 circle 150x220 10 line 50x110 120x60 line 200x60 250x110 ] ] ] BTW, Why is my mouth a box? Brett.
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted