Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WISH: on-scroll for text-list and API to control it #152

Open
GiuseppeChillemi opened this issue Oct 22, 2023 · 0 comments
Open

WISH: on-scroll for text-list and API to control it #152

GiuseppeChillemi opened this issue Oct 22, 2023 · 0 comments

Comments

@GiuseppeChillemi
Copy link

VID does not have a multi-column text-list. You can connect multiple single text-lists and propagate the on-change event but you end up in a problem: they will go out of sync. To solve the problem you can try to position to 1 and then to the requested position but it is kludgy. I have tried with this tecnique and the result is not good. Also you CAN'T use the scroller as you do not have an on-scroll actor so using it you will lose the row syncing.

Here is the code I have created

Red [
	title: "Multi Text List"
]


l: copy []
list-size: 3
list-name: 'one

;--- Creates a list with multiple columns

repeat idx 50 [
	append l compose [(rejoin ["a" idx]) (rejoin ["b" idx]) (rejoin ["c" idx])]
]




select-everywhere: func [
	"Select the same element on all lists"
	face [object!] "The current face"
	id [word! string!] "The id of the list"
	position [integer!] "The position to select"
] [
	;--- This is needed for syncing
	foreach-face/with face/parent [face/selected: 1] [attempt [face/extra/list-id = id]]

	;--- This repositions everywhere
	foreach-face/with face/parent [face/selected: position] [attempt [face/extra/list-id = id]]
]


make-list-view: func [
	"Create a navigable list made of multiple text-lists"
	data [block! object!] "The table as flat"
	col-ln [integer!] "The lenght of columns"
	list-id [word! string!] "The name of the list"
	/local
	template
	row
	list-body
] [
	;The basic template for the list
	template: [
		style clist: text-list data "" on-change [select-everywhere face face/extra/list-id face/selected]
	]
	
	;Init of the list body
	;
	list-body: copy template

	;The text-list that manages a column
	;
	row: [clist data "" with [extra: make object! [list-id: quote (list-id) data: l column: (col-num) original-data: data] data: extract/index l (col-ln) extra/column]] 


	;Creating the code that manages alla the columns
	;
	repeat col-num col-ln [
		append list-body compose/deep copy row
		
	]

	;Returning the list VID code
	;
	list-body
]

view make-list-view l list-size list-name

My request is for an on-scroll actor and expose the API elements to get/set the position of the list like the first/last visible row number, number of rows on screen.

Some screen-capture and discussion is here.

Thank you in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant