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

World: r3wp

[View] discuss view related issues

Henrik
11-Nov-2005
[3160]
I'm trying to make a button behave like a text field, but I can't 
make it work.


view layout [b: button "Hello" with [flags: [field input return text]]]

what's missing?
Volker
11-Nov-2005
[3161]
the right feel?
Henrik
11-Nov-2005
[3162]
could be...
Geomol
11-Nov-2005
[3163]
Try:
layout [f: field "Hello"]
probe f/feel
Henrik
11-Nov-2005
[3164]
volker, geomol, thanks! it was correct
Graham
14-Nov-2005
[3165x2]
I've been playing around with Frank's paint.r in the library.  I 
implemented a free hand draw tool but found that a simple line or 
circle takes about 32k of draw instructions :(
I wonder if there's a more efficient way to do this than combining 
lots of line draws together?
Ashley
14-Nov-2005
[3167]
It's a simple problem of polling frequency. Try changing the code 
so that a new point is not placed unless it is more than (say) 4x4 
away from the previous point.
Anton
14-Nov-2005
[3168x3]
I see. I noticed also that the DRAW function adds
	PEN pen-col FILL-PEN fill-col LINE start offset
for every new point, when what is necessary is only new offsets.
I suggest to add an OLD-TYPE variable, and put something like this 
in the DRAW function:
	either all [type = 'free-hand type <> old-type][
		; add all the initialising stuff (PEN FILL-PEN, LINE start)
	][
		; otherwise compose in nothing
	]
So when you change from circle to free-hand, DRAW adds the initialising 
draw commands, but after that, just adds an offset.

Ooops, I should have checked for type = old-type so we can add the 
single offset. Anyway, you get the idea. Just move that condition 
inside the either true block.
Henrik
15-Nov-2005
[3171]
hmm... how do I set the default entry in a CHOICE at layout time? 
I wanted to do something like this:

view layout [choice "1" "2" "3" with [data: next face/data]]
RobertDumond
15-Nov-2005
[3172x4]
hallo, alls... i have a question regarding view events...  i am testing 
using the following code, which creates two text fields, one of which 
only accepts numerical input...
view/new layout [
    the-field: field feel [
        engage: func [face action event] [
        	if action = 'key [
			if all [ greater? (to-integer event/key) 47
				 lesser? (to-integer event/key) 58 ] [
				 append face/text event/key 
				 show face 
			]
		]    
        ]
    ]
    new-field: field
]
focus the-field
do-events
first question, is how can i get the first text field to accept mouse 
click events?  how then do i get it to recognize the tab key to switch 
focus to the next field?
also, can i update the position of the text curser in the number 
field so that it is the current position being typed at? (bad wording, 
i know... )
Henrik
15-Nov-2005
[3176]
robert, what happens in the above code is that you replace the original 
feel functions with one ENGAGE function. that's why you loose normal 
field functionality
RobertDumond
15-Nov-2005
[3177]
is there an alternate way i should be doing this?
Henrik
15-Nov-2005
[3178x4]
you need to copy in the original feel from a generic field face into 
your new field along and then add your code to its existing engage 
function
it's a bit of a hassle...
try:

probe get in new-field/feel 'engage

that's the original code
that's the code you need to alter...
RobertDumond
15-Nov-2005
[3182]
thank you, i will try that
Henrik
15-Nov-2005
[3183x2]
you can copy it out into a separate function, which could be called 
ENGAGE-FUNC and make you alterations.


then you can initialize a normal field with a new ENGAGE function 
in your layout:

the-field: field with [feel/engage: :engage-func]
this will leave the remaining feel functions untouched
Geomol
15-Nov-2005
[3185x3]
Henrik, your choice problem. I think, you have to redefine choice. 
The problem is in the multi/text function. You can do it at layout 
time this way:

view layout/size [choice "1" "2" "3" with [multi/text: func [face 
blk] [if pick blk 1 [face/texts: copy blk]] text: "2"]] 400x400
It's better to make your own choice with your own multi/text function.
using styles for example.
Henrik
15-Nov-2005
[3188]
thanks, I'll give it a try...
Volker
15-Nov-2005
[3189]
http://polly.rebol.it/test/test/extend-engage.r
Graham
15-Nov-2005
[3190x3]
I want to save my draw commands to a text database field.
is this the only way

form compress mold data  ?
the question really is, is there a native way to compress blocks 
as a string value ( for saving into a text field )
Volker
15-Nov-2005
[3193]
by molding them
Graham
15-Nov-2005
[3194x2]
does molding save space though?
that's what I am doing above, molding and then using using compress
Volker
15-Nov-2005
[3196]
no, but then you have a string. then you can compress. then you can 
write/binary .
Graham
15-Nov-2005
[3197]
text field .. can't save as binary.
Volker
15-Nov-2005
[3198x2]
i overlooked text-field, only saw saving.
why do you want to do that, compressed in a field?
Graham
15-Nov-2005
[3200x2]
because the field is varchar(8192)
and data is being transmitted over tcp, so good to compress first
Volker
15-Nov-2005
[3202x2]
a sql-field, not a face-field?
you can use 'as-string instead of 'form. but i know no better way 
that "compress mold".
Graham
15-Nov-2005
[3204x2]
sql field
perhaps we native to compress rebol code and return as a string value, 
and not binary
Volker
15-Nov-2005
[3206]
you can convert a binary to a string in place, with 'as-string
Graham
15-Nov-2005
[3207]
I wonder if that will save okay though 


>> t: as-string compress mold [ font bold32 pen yellow red line-pattern 
5 5 line-width 2 ]

== {xœ‹NËÏ+QHÊÏI16R(HÍS¨LÍÉÉ/W(JMQÈÉÌKÕ-H,)I-ÊS0^EB°@yfJI†‚Q,^@\Z^T^T:^@^@^@}
Volker
15-Nov-2005
[3208]
with write/binary yes. dont know what the sql-protocol does.
Graham
15-Nov-2005
[3209]
>> t

== {xœ‹NËÏ+QHÊÏI16R(HÍS¨LÍÉÉ/W(JMQÈÉÌKÕ-H,)I-ÊS0^EB°@yfJI†‚Q,^@\Z^T^T:^@^@^@}

>> insert db-port [{update results set draw = (?) where rid = 174} 
t ]
>> insert db-port {select draw from results where rid = 174}
>> r: pick db-port 1

== [{xœ‹NËÏ+QHÊÏI16R(HÍS¨LÍÉÉ/W(JMQÈÉÌKÕ-H,)I-ÊS0^EB°@yfJI†‚Q,^@\Z^T^T:^@^@^@}]
>> decompress to-binary r/1
== {[font bold32 pen yellow red line-pattern 5 5 line-width 2]}
>>