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.
----- Original Message -----
From: "Cyphre"
Sent: Friday, October 10, 2003 8:30 PM
Subject: [REBOL] Re: [View] dirty?
>
> Hi Ingo,
>
> I don't know it this if easiest but try this:
>
> find-dirty: func [fac][
> if fac/pane [
> foreach f reduce to-block fac/pane [
> first f
> if all [find first f 'dirty? f/dirty?][
> print [f/var "is dirty!"]
> ]
> find-dirty f
> ]
> ]
> ]
>
> example:
>
> view lay: layout [
> f1: field
> panel yellow 240x65 [
> f2: field
> ]
> button "find dirty" [
> find-dirty lay
> ]
> ]
>
> You can generalize the function for recursive search of any face's
> property...
>
> regards,
>
> Cyphre
>
> ----- Original Message -----
> From: "Ingo Hohmann"
> Sent: Friday, October 10, 2003 11:25 AM
> Subject: [REBOL] [View] dirty?
>
>
> >
> > Hi All,
> >
> > what's the easiest way to find out, if a layout contains any dirty
fields?
> > (That is, fields that have been edited).
> >
> >
> > Thanks to all who might anwer
> >
> > Ingo
> >
> >
> > --
> > To unsubscribe from this list, just send an email to
> > [EMAIL PROTECTED] with unsubscribe as the subject.
> >
> >
>
> --
> To unsubscribe from this list, just send an email to
> [EMAIL PROTECTED] with unsubscribe as the subject.
>
>
--
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.