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

World: r3wp

[View] discuss view related issues

james_nak
17-Nov-2008
[8287]
I'm trying to create a function that builds radio buttons and checkboxes 
on the fly. Sunanda gave me some ideas about how to do that. This 
morning it dawned on me that I was going about it the wrong way. 
I was trying to build an entire string that represented the rebol 
code for the gadget instead of building a block of code.. What was 
happening was my contexts were all in error. 

I'm wondering now how to append my code into an existing layout block. 
The only working method I have found so far is to append into a non-layout 
block then "view layout blk." I'm still curious if there is a way 
to append/insert into a layout block though. E.g., 
a: layout [ btn "Quit" [unview halt] ]
b: [t1: check [ ] ]   <- this is my generated block
append a b

I get a "Script Error: append expected series argument of type: series 
port"
Henrik
17-Nov-2008
[8288x2]
remove the first layout and then create the layout afterwards.
all LAYOUT does is create a big object tree, and of course you can't 
just append blocks to that
james_nak
17-Nov-2008
[8290]
Thanks Henrik. That's what I needed to hear (how layout works).
Nicolas
17-Nov-2008
[8291x3]
insert-event-func [
	if event/type = 'key [
		print face/text
	]
event
]
view layout [area "hello"]

;Can a/text update before it prints?
;There's a one keystroke delay
that should be view layout [a: area "hello"]
Anton
17-Nov-2008
[8294]
Nicolas, you could modify the area's engage function, as in this 
patch.

append blk: select select second get in a/feel 'engage [switch act][key] 
bind [print face/text] blk/2
Nicolas
17-Nov-2008
[8295]
Thanks Anton. That was really helpful.
Anton
17-Nov-2008
[8296]
You're welcome.
Nicolas
21-Nov-2008
[8297x4]
REBOL []

index: func [dir list /local files] [
	files: sort load dir
	foreach file files [append list join dir file]

 foreach file files [attempt [if find file "/" [index dir/:file list]]]
] index %/c/ files: []

l: layout [
	f: field 600 [call t/picked]
	t: text-list 600x400 data copy files] 

search: func [f-string] [
	t/data: copy files  

 foreach s parse f-string none [remove-each f t/data [not find f s]]
	show t]


append blk: select select second get in f/feel 'engage [switch act][key] 
bind [search f/text] blk/2

focus f view l



if I type something into the field, then I click the slider, it calls 
t/picked. Why? i can't figure it out.
Sorry. That should be this.
index: func [dir list /local files] [
	files: sort load dir
	foreach file files [append list join dir file]

 foreach file files [attempt [if find file "/" [index dir/:file list]]]
] index %/c/ files: []

l: layout [
	f: field 600 [call t/picked]
	t: text-list 600x400 data copy files] 

search: func [f-string] [
	t/data: copy files  

 foreach s parse f-string none [remove-each f t/data [not find f s]]
	append clear t/picked t/data/1
	show t]


append blk: select select second get in f/feel 'engage [switch act][key] 
bind [search f/text] blk/2

append clear t/picked t/data/1
focus f view l



if I type something into the field, then I click the slider, it calls 
t/picked.
Why?
Anton
21-Nov-2008
[8301x4]
This is just the same as:
	view layout [
		field [call t/picked]
		t: text-list
	]
It calls t/picked because [call t/picked] is the action block specified 
after FIELD.
Are you confused about action blocks in VID ?
Ah sorry, it's when you click the slider that the field action is 
done (unexpectedly by you).
It's ON-UNFOCUS in face flags.  Compare:
	view layout [f: field [print "action"] text-list]
	print mold f/flags

 view layout [f: field [print "action"] with [deflag-face self on-unfocus] 
 text-list]
	print mold f/flags
james_nak
22-Nov-2008
[8305]
As I have mentioned before here I have been working on turning strings 
into code. I've used this:
set in get to-set-word "myobj" 'text   "change a value"
where myobj: make object! [text: "default"]

and this works! I just don't know why  get to-set-word "myobj"  behaves 
that way. I'm hoping it's not a fluke because it's my Mr. Helper. 
Anyone able to explain that?
Anton
22-Nov-2008
[8306x2]
You can get from a word! as well as the corresponding set-word! and 
get-word!.  They are all the same word, after all.
So, in your example, you could replace TO-SET-WORD with TO-WORD.
james_nak
22-Nov-2008
[8308]
I see. But what am I "getting"?
Anton
22-Nov-2008
[8309]
GET gets the value of the word, which you previously set to an object. 
So, GET returns that object.
james_nak
22-Nov-2008
[8310x3]
Then the to-word just know by context that myobj was an object, eh? 
 The reason I ask that is that if  it was just a word and not an 
object I don't seem to have to use get.:
>> a: "test"
== "test"
>> set to-word "a" "hello"
== "hello"
>> a
== "hello"
>> set in to-word "myobj" 'text "hello"
** Script Error: in expected object argument of type: object port
** Where: halt-view
** Near: set in to-word "myobj" 'text
>> myobj/text
== "eeee"
>> set in get to-word "myobj" 'text "hello"
== "hello"
It's all good. I just was curious. Thanks Anton.
Nicolas
22-Nov-2008
[8313]
Thanks Anton!
Anton
22-Nov-2008
[8314x2]
Nicolas, you're welcome.
James, TO-WORD does not interact with the value of the word it is 
creating.
RobertS
22-Nov-2008
[8316]
glad to see VID3 with ability to
   some-useful-name: "you will debug listbox3 someday" 
   attach 'some-useful-name
Graham
26-Nov-2008
[8317x2]
I can't remember now .. but how do you start a rebol process with 
a systray?
I mean you start the systray with do-events, but then you can't start 
your forever [ process ]
BrianH
26-Nov-2008
[8319]
I thought you used the system:// port.
Graham
26-Nov-2008
[8320x3]
I guess if you're using a gui, you can kick off your process with 
a timer event on a face ...
Just wondering how's it's done with just the systray icon and no 
GUI
and no console
Gabriele
26-Nov-2008
[8323x3]
graham, maybe look at my clips.r script, it is systray only.
http://www.colellachiara.com/soft/MD3/examples/clips.html
http://www.colellachiara.com/soft/MD3/examples/clips.r
Graham
26-Nov-2008
[8326]
Thanks
Graham
28-Nov-2008
[8327]
I've abstracted the systray/forever loop out here 
http://rebol.wik.is/Code_Samples/Systray.r
Maarten
28-Nov-2008
[8328]
S3 backup? You have plans..... beware that for large volumes you 
*have to* parallelize. SQS is there for a reason
Graham
28-Nov-2008
[8329]
Yes ... but it's for small volumes ... maybe a few gbs only
Rod
28-Nov-2008
[8330x2]
Is there an option to have no caret but capture keyboard events? 
 I'd like to get navigation keys for example but don't want a visible 
caret.
I see notes about using detect for hot keys instead of engage, is 
that the best way or is there a way to turn the caret part off?
Henrik
28-Nov-2008
[8332]
FOCUS/NO-SHOW will hide the caret.
Rod
28-Nov-2008
[8333]
Thanks Henrik, exactly what I was looking for.
Anton
29-Nov-2008
[8334x3]
There's  a problem with that, in that as soon as you show a parent 
face, the caret will appear, because the subface will also be rendered 
by SHOW.
So if you SHOW the window face that the field is in while the field 
has the caret, then the field will be SHOWn as well, and the caret 
will be rendered.
If you look in the source of FOCUS, you can see what it's doing. 
Just do the same, except without setting the caret.