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

World: r3wp

[View] discuss view related issues

Maxim
15-Sep-2009
[9129x2]
yes and it continues to send it away events every time you cross 
the boundry of a face !
anyone know a way to prevent text-list from picking more than one 
item with ctrl?
BenBran
23-Sep-2009
[9131]
I need some clairfication in reading the syntax/specs for Rebol2.x 
stuff.
I'm sure there is a pattern, but I havn't seen it yet.

Example: taken from rebol.net/wiki/VID:_Styles#Derived_styles_2

TEXT-LIST
   size: pair!
   rows: block!

   selected: block! ; this way set-face will not work. need to solve 
   this.
   action: block!
   background: tuple!
   background-draw: block!

how do I know when to assign a value to a [word] i.e. 

lo: [text-list size: 300x200]		;;does not work 
view layout lo

and when not to use the [word] such as 

lo: [text-list 300x200] 	;; works
view layout lo


Question 2. Could someone give a one line (short as possible) example 
of setting all the values for this text-list keyword using this format 
lo: [text-list ......]
view layout lo

thanks in advance.
Henrik
23-Sep-2009
[9132]
The guide you are using is for VID3 for REBOL 3, which is no longer 
in use.
Dockimbel
23-Sep-2009
[9133]
The documentation you've pointed to seems related to R3, not R2.x. 
There's no header info in that page, so just guessing. 

You'll find REBOL 2.x view documentation here : http://rebol.com/docs.html

More precisely:
http://rebol.com/docs/view-guide.html

http://rebol.com/docs/easy-vid.html#section-14	(for TEXT-LIST examples)


About your question, here's a more complete example (not sure that 
all possible options are there, thought) :


lo: [text-list 300x200 yellow blue data ["one" "two" "three"] [print 
"action"]]
view layout lo
BenBran
23-Sep-2009
[9134x2]
Thank you both.  Is it possible to create columns as well or is text-list 
a single column entity?
or maybe incorporate tabs?
Dockimbel
23-Sep-2009
[9136x3]
AFAICT, text-list is single column. Henrik has done some nice new 
components for VID, his LIST-VIEW style should fullfill your needs. 
Have a look at : http://www.hmkdesign.dk/rebol/page0/page0.html
Here's a quick link to what you're looking for : http://www.hmkdesign.dk/rebol/list-view/docs/list-view.html#section-3
Btw, here's another useful link about VID styles : http://www.codeconscious.com/rebol/vid-notes.html
BenBran
23-Sep-2009
[9139]
thanks for the links.  I do have that list-view, I was trying to 
find a smaller way out.  It was missing one or two features I was 
wanting last I checked, and didn't feel like pouring over the source 
code.  about 100 pages.  My brain would take quite a few months to 
understand it.   Excellent software though.  I'll give it some more 
thought, and thanks again for the vid-notes link.  It looks very 
clean.
Dockimbel
23-Sep-2009
[9140x2]
Digging out the old but still very good for quick VID learning vid-usage.r 
script: http://www.rebol.org/view-script.r?script=vid-usage.r
If you want a small solution, you can use the LIST style, but it's 
a bit more complex to work with. You can find some examples in the 
vid-usage.r script (look of some examples is horrible, but it will 
show you how to build custom multi-column lists).
BenBran
23-Sep-2009
[9142]
well.... looking back through my coded examples... I actually have 
a good working list-box with over l000 rows with the columns correctly 
spaced.  However, its missing some necessary features, one of which 
is how do i attach the vertical scrollbar to the list box.   I tried 
the vid-usage.r script but perhaps I must have missed some key elements. 
 I'll try looking at that again.
Dockimbel
23-Sep-2009
[9143x4]
I wrote a quick example to show you how to achieve that : ]
data: make block! 16

loop 16 [repend/only data [random "012345789" random "abcdefghij"]]

visible: 5					; number of visible lines
window: (length? data) - visible	; sliding window size
cursor: 0

view layout [
	across
	space 0x0
	
	grid: list 200x100 [
		across
		txt 100
		txt 100
	] supply [	
		if row: pick data count + cursor [face/text: pick row index]
	]
	sc: scroller 16x100 [
		cursor: sc/data * window
		show grid
	]
	do [
		sc/step: 1 / window		; initializing scroller steps granularity
	]
]
Forgot to set the scroller bar size, the 'do init code should be 
:

	do [
		sc/step: 1 / window		; initializing scroller steps granularity
		sc/redrag 5 / length? data	; initializing scroller bar size
	]
or even better : sc/redrag visible / length? data
BenBran
24-Sep-2009
[9147]
That is an excellent example.  Answered many questions I had (and 
raised a few more).  Thank you for taking the time to show me this 
Dockimbel.
Dockimbel
24-Sep-2009
[9148x2]
I'm glad it helped you. It was a good opportunity for me to refresh 
my memory about the (powerful but under-documented) LIST style.
In case you're wondering about the block after SUPPLY, it's used 
internally by the LIST style to build an iterating function defining 
a local context where COUNT refers to the current row and INDEX to 
the current column. Each horizontally positionned face (purpose of 
the ACROSS keyword) defined in the LIST layout block, is counted 
as a column, so: txt 100 txt 100 => 2 columns.
amacleod
24-Sep-2009
[9150]
I'm need to get the name I assigned a face when I alt-click on it. 
I can get its style, offset, size etc but I do not see a way to get 
the face's name. More specificly I have multiple scroll-panels and 
I need to know the one I'm clicking in...
Graham
24-Sep-2009
[9151]
What name?
amacleod
24-Sep-2009
[9152x3]
a: scroll-panel [blah blah blah
b: scroll-panel [blah blah blah

I want to know if I clciked in scroll-panel a or b
if event/type = 'alt-down [face/style]

...gives me 'scroll-panel'

how do i get 'a' or 'b'
Sorry for the possible confusion but its one of anton's styles but 
did not think it would make a diff.
Graham
24-Sep-2009
[9155]
face = a ??
Henrik
24-Sep-2009
[9156]
face/var
amacleod
24-Sep-2009
[9157x2]
yeah?
it works...
Henrik
24-Sep-2009
[9159]
of course it does :-)
amacleod
24-Sep-2009
[9160x2]
I thought about var but I thhought that would be too simple to work...
Thanks alot Henrik!
Is that because its Anton's style or is that a rebol thing for all 
faces?
Henrik
24-Sep-2009
[9162x2]
no problem
face/var is set during layout for all faces that have a set-word! 
attached.
amacleod
24-Sep-2009
[9164]
great! Thanks!
Henrik
24-Sep-2009
[9165x4]
you can also set it yourself like this:

scroll-panel [with: 'a]
oops
scroll-panel with [var: 'a]
but when you do that, there is no global word set. it can still be 
useful however, if you desire to recognize a face using different 
means, like traversing a pane for a specific face.
amacleod
24-Sep-2009
[9169]
good to know
Graham
24-Sep-2009
[9170]
Must be a VID thing.  Rebgui doesn''t do this AFAIK
Henrik
24-Sep-2009
[9171]
this is done in the LAYOUT function. good one to study:

source layout
Maxim
24-Sep-2009
[9172]
face/var !!! OMG never knew this.... hehe

amacleod,    there's always stones unturned in REBOL even for us 
advanced users ;-)
Anton
25-Sep-2009
[9173]
I reckon you did know this,. Maxim, but you just forgot about because 
it's not needed so much.

What I do, which is more simple and direct, is just compare face 
with the word I previously set it to, eg:

	my-scroll-panel: scroll-panel

and later in the event handler just

	if face = my-scroll-panel [...]


This is just comparing two object references for equality, which 
is more fundamental and doesn't need any facility of VID.
amacleod
25-Sep-2009
[9174]
Thanks, I'll try that too Anton.


I was not able to gfet Henricks suggestion to work when placing the 
event handler in the main program...it only worked when placed in 
the seperate scroll-panel.r file.
Maxim
25-Sep-2009
[9175]
I always setup stuff in the object directly using the with block. 
I was just amazed that after so long, such a feature is still unknown 
to me.  :-)
Anton
25-Sep-2009
[9176]
Eh? You really ought not to have to modify the scroll-panel.r file. 
That's just going to cause problems for you down the line, because 
you are forking. You should be able to override the default scroll-panel 
feel in your user code. Just let me know what you're trying to do 
with that and I'll show how.
amacleod
25-Sep-2009
[9177]
Anton, I had the same worry about forking....

this addition/change to scroll-panel.r works: 

detect: func [face event][
	if event/type = 'alt-down [	
		if face/var = 'my-scroll-panel [ print "hello"]
	]
	event
]

But this addition to global handler does not: 

alt-detect: func [face event][
	if event/type = 'alt-down [	
		if face/var = 'my-scroll-panel [ print "hello"]
	]
	event
]
insert-event-func :alt-detect

get error on face/var
Anton
26-Sep-2009
[9178]
Yes, probably because not all faces in the system are VID faces. 
A VID face is an extension of system/standard/face with several facets 
added, including VAR.

If the event handler came across a non-VID face, then face/var is 
an invalid path.

So you see, this is an example of why using this method to identify 
a face is more brittle.
You should better use:

	face = my-scroll-panel

to determine identity of a face.