[REBOL] Re: [View] dirty?

2003-10-18 Thread Ingo Hohmann

Thanks to all who answered,

Volker Nitsch wrote:
 my most robust approach is:
 keep a copy of the last content and compare.
 rebol has a culture of changing variables directly
 (face/text: Hello)
 and then calling a general process-function
 (like show face - face/feel/redraw) 
 with keeping old version you can change
 face/text with no need for some [face/dirty: true]
 -Volker

The problem in my case is, that I don't have a special edit mode, I 
display the information, and it can at the same time be altered by the 
user. Furthermore, it is a dynamically created layout with no _single_ 
point of exit.

It had been so nice, if the dirty flag would have been accurate, and 
promoted through the hierarchy - a face get dirty, whenever one of its 
subfaces gets dirty, if a parent face gets the dirty bit cleared, all 
subfaces get it cleared, too.


Kind regards,

Ingo


-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: [View] dirty?

2003-10-15 Thread Volker Nitsch

my most robust approach is:
keep a copy of the last content and compare.
rebol has a culture of changing variables directly
(face/text: Hello)
and then calling a general process-function
(like show face - face/feel/redraw) 
with keeping old version you can change
face/text with no need for some [face/dirty: true]
-Volker

Am Freitag, 10. Oktober 2003 17:56 schrieb [EMAIL PROTECTED]:
 Ingo:
  what's the easiest way to find out, if a layout contains any dirty
  fields? (That is, fields that have been edited).

 I don't know the *easiest* but what I do is set a global variable in each
 field I'm interested in. Something like:

 ; function to set global flag if field has changed
 global-dirty?: false
 set-dirty?: func [face [object!]]
 [
  if strict-not-equal? face/data  face/user-data
 [print face value changed
  face/user-data: copy face/data
  global-dirty?: true
 ]
 ]

 ;; sample layout using above function

 unview/all
 view layout [field [set-dirty? face]
 field [set-dirty? face]
 button Exit [If global-dirty?
 [print need to save here
  global-dirty?: false
 ]
 ]
 ]

 This method is precise it that you set global-dirty? only for the fields
 you care about. But it's annoying in that you need to add a  [set-dirty?
 face] to all those fields.

 It works for me in the application I use it in because the layout is built
 from a template, so I don't have to insert the [set-dirty? face] by hand
 everywhere.


 You could play with making it more flexible by exploring using styles. This
 next example does that. It also defines its own 'last-user-value variable
 rather than using 'user-data. And it fixes the false positive when you
 tab out of a field for the first time:

 global-dirty?: false
 set-dirty?: func [face [object!]]
 [
  if strict-not-equal? face/data  face/last-user-value
 [print face value changed
  face/last-user-value: copy face/data
  global-dirty?: true
 ]
 ]

 unview/all
 view layout [style monitored-field field
 with [last-user-value: copy ]
 [set-dirty? face]

 monitored-field [set-dirty? face]
 monitored-field [set-dirty? face]
 button Exit [If global-dirty?
 [print need to save here
  global-dirty?: false
 ]
 ]
 ]

 Sunanda.


-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: [View] dirty?

2003-10-10 Thread Brett Handley

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.



[REBOL] Re: [View] dirty?

2003-10-10 Thread Romano Paolo Tenca

Hi Brett,

 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.

dirty? is used internally by the standard rebol focus system. I would not use
it to check if a field changed, because it is cleared by the focus system
under some conditions (which could change in future). I would consider it a
private flag.

---
Ciao
Romano

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: [View] dirty?

2003-10-10 Thread Anton Rolls

You could use query on the face, which is,
after all, just an object.

que: does [probe query/clear f]
query-f: does [que show f que]
view layout [
f: field hello
button change text [f/text: random abcd query-f]
button change size [f/size/x: 100 + random 100 query-f]
]

Anton.

 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.