r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[View] discuss view related issues

Maxim
13-May-2010
[9893x3]
add a show to it... might just not be refresing itself.
ah.
probably just need to 'REDUCE your fields block first.
its not receiving an object as its first parameter

fields: reduce [a b c]

foreach field fields [
	set-face field now
]


btw... use the 'source command whenever you get these types of errors.

>> source set-face
set-face: func [

    {Sets the primary value of a face. Returns face object (for show).}
    face
    value
    /no-show "Do not show change yet"
    /local access
][
    if all [
        access: get in face 'access
        in access 'set-face*
    ] [
        access/set-face* face value
    ]
    if not no-show [show face]
    face
]
amacleod
13-May-2010
[9896x2]
I never use set-face either but I'm tired of setting a bunch of fields 
manually
The fields need to stay as word! 

If I reduce them they will give me their current value...
Maxim
13-May-2010
[9898x2]
remember that even if [a b c] are bound... they will still be passed 
as words to the function in your loop.


another way is to use 'GET directly on the words within the loop, 
but that can have hard to understand binding side-effects, depending 
on how the block was originally created.
example using 'GET

fields:  [a b c]

foreach field fields [
	set-face get field to-string now
]
amacleod
13-May-2010
[9900]
that works...thanks

but I do not fully get it...I look into it.
Maxim
13-May-2010
[9901x2]
GET gives you the value of a word.  


the detail being that the word may or not be bound.  when it isn't 
bound explicitely, it will search for it in the global context (explicitely 
if you give it a lit-word).


which is why its always a good idea to use GUI code within a context, 
so you can be sure any un-explicit binding is local to that context. 
 note that you must explicitely create them within the context (at 
the root level of the context) for that binding to occur.


(note to Lad & Brian..I know I'm over-simplifying the whole concept, 
but that is how basically it works for "mere mortal"  ;-)

ex: 
here .... danger!   [a b c] use isn't bound within the context.

context [
	layout [a: field b: field c: field]

	fields: [a b c]
	foreach field fields [
		set-face get field to-string now
	]
]





while this will be (and protect your global context from being clobbered 
by the field names), plus you are sure that GET will try to use the 
field names locally.

context [
	a: b: c: none

	layout [a: field b: field c: field]

	fields: [a b c]
	foreach field fields [
		set-face get field to-string now
	]
]



if you really wanted to be funky, you could put words in the [a b 
c] block which are bound to other contexts using 'IN.

append fields [] IN other-context 'd


then when the loop runs, the field specified by d in that OTHER context 
will also be set.
hehe... that seems like it was a "Binding 101" tutorial   hehehe
amacleod
13-May-2010
[9903]
That helps...I think. thanks
Maxim
13-May-2010
[9904]
using the above tricks you can make system-wide intialisation functions:


here is a cool previous login detection system which fills up your 
whole gui based on stored data in a database.

	

; supply contexts, view controls set into them and the data to set 
into.
setup-all-gui: func [
	spec 
	/local ctx control controls data i
][
	foreach [ctx controls data] spec [
		repeat i length? controls [
			control: get in ctx controls/:i
			set-face control data/:i
		]
	]		
]
	
; reload previous session
either all [

 main-data: get-sql-last-main-data  ; returns [ "project" "module"]

 login-data: get-sql-last-login    ; returns ["user" "encrypted" "server.com"]
][
	setup-all-gui reduce [
		main-gui [proj-fld mod-fld] main-data  
		login-gui [login-fld passwd-fld server-fld] login-data
	]
][

 print "This is the first time you use application, user-setup will 
 now be called."
	setup-user
]
Henrik
15-May-2010
[9905]
is it not possible to capture ctrl+tab?
Pekr
15-May-2010
[9906]
no ... that is my old-time complaint ... ctrl tab is needed to swithc 
between tabs ....
Henrik
15-May-2010
[9907]
ok, thanks
Graham
24-May-2010
[9908]
http://www.rebol.com/downloads/v277/viewpro-277-agg-fix1.exe
Henrik
26-May-2010
[9909x2]
are there known problems with RATE inside a DETECT? when I use it, 
EVENT/TIME is fired constantly, even if I set rate to something like 
0:0:10.
whoops, I meant event/type = 'time, not event/time.
Steeve
26-May-2010
[9911]
you need to do a show of the face to have the rate taken in account.
Maxim
26-May-2010
[9912x3]
here is how it works..... I had to stumble upon this within GLASS.


when you add a rate to a face, actually, the timer will trigger 30 
times a second, no matter what your rate is.

do event

will filter the events based on what your rates are set up.
because detect is part of the wake-event system, it gets all the 
events from the input stream, so you end up with all time events.
it was done this way so view can share the same time event among 
many faces, internally.
Henrik
26-May-2010
[9915]
ok, I see.
Maxim
26-May-2010
[9916]
It took me quite a while to figure out what I called "Time event 
madness"  ;-)
Henrik
26-May-2010
[9917]
ok, the "do event" thing? when do I apply that?
Maxim
26-May-2010
[9918x2]
that managed within the do-event of wake-events.


the fact that  detect is called, means do event was called.  whenever 
a detect returns false, it consumes the event and subfaces do not 
get their events (even time IIRC).
sorry...  "that managed within the do-event of wake-events"  should 
read

that's managed within view's port wake-event
Steeve
26-May-2010
[9920]
IIRC the corrected time event is kept by engage, not detect.
Maxim
26-May-2010
[9921]
exactly.
Henrik
26-May-2010
[9922]
ok, I've added a delay handler, but it seems a bit wasteful to do 
it this way.
Steeve
26-May-2010
[9923x2]
use engage not detect to trap the time event accordingly with the 
rate
and after changing the rate of a face you need to issue immedialty 
a SHOW on the face
Henrik
26-May-2010
[9925]
hmm...
Steeve
26-May-2010
[9926]
using detect slow down your app, avoid it if you can
Maxim
26-May-2010
[9927]
detect should only be used to trap events to sub-faces.   as Steeve 
notes, engage is where you should really be handling the events.
Henrik
26-May-2010
[9928]
I'm messing around in the detect function for the main window.
Maxim
26-May-2010
[9929x2]
aaahhhh lots of "fun" isn't it   ;-P
you might be better of using an input even handler, its faster cause 
it proceeds at the very start of do events... before it starts looking 
at faces within panes.
Henrik
26-May-2010
[9931]
seems that engage has no effect. so you are not supposed to be able 
to use engage and detect at the same time in the same face?
Maxim
26-May-2010
[9932]
it depends what you return from detect.  if you return none, it consumes 
the event, if you return the event, then engage is called.

that's how its supposed to work, AFAIK.
Henrik
26-May-2010
[9933]
I return the event, yet nothing happens. Oh, well, I've studied RebGUI 
code and it does the same thing as I do.
Maxim
26-May-2010
[9934x2]
strange.
what are you trying to achieve?
Henrik
26-May-2010
[9936]
I just want a delay before displaying a tool-tip anywhere in the 
window.
Maxim
26-May-2010
[9937]
you do know that the window feel is replaced everytime it is viewed?
Henrik
26-May-2010
[9938]
yes, I take care of that just fine. I've made plenty of modifications 
to the detect function for window already.
Maxim
26-May-2010
[9939]
ok, just reminding you,  its bitten me in the arse a few times, even 
if I know about it  ;-)
Henrik
26-May-2010
[9940]
yes, it's not easy, however everything is working as expected, except 
for time events and the use of engage.
Maxim
26-May-2010
[9941x2]
its possible the window cannot have time events, no matter its rate. 
 try using a master face in which you put everything, using its feel 
instead.


the window is managed differently than other faces by view... it 
has its own events like resize and stuff, so I wouldn't be surprised 
that its time handling is different.
(I meant, support for time events in its engage)