[REBOL] Re: [View] dirty?
From: brett::codeconscious::com at: 11-Oct-2003 0:57
Hi Ingo, Cyphre,
I'm not sure you can use the dirty? flag for testing if data has changed. It
doesn't seem to behave as I would expect. For example, in Cyphre's example
without hitting the Enter key or the Tab key, enter some information into
both the fields and try the button. For me, no dirty faces are found. Only
once I hit the Enter key does the routine work.
I think it might be better to set your own dirty flag during an action
block, or check for differences between old-values and new-values at an
appropriate moment (eg close window / save, etc.).
Cyphre, the find-dirty function has a little problem - it does not take into
account where a pane is of type function!. For example, include a text-list
in the panel.
Ingo, don't forget to check what happens when you enter a value in the field
and immediately close the window without hitting the Enter key - you might
need a event handler function. Details here:
http://www.codeconscious.com/rebol/view-notes.html#DirtyFaces
For interest, here's some face searching functions I made:
http://www.codeconscious.com/rebsite/rebol-library/face-searches.r
and Cyphre's example modified a bit to use one of them:
view lay: layout [
f1: field [probe "f1"]
panel yellow 240x400 [
f2: field [probe "f2"]
f3: text-list data copy/deep system/locale/months [probe "f3"]
]
button "find dirty" [
repeat f find-faces [
all [in face 'dirty? face/dirty?]
] [
print [f/var "is dirty!"]
]
]
]
Regards,
Brett.