Re: Fast way to highlight a listbox entity selection
Hi JPR, Fuzziness is a good description, but things stand in sharper relief today. I was more focused on the syntax than the mechanics and for no particular reason started out with collections. Converting the app to an entity selection approach is turning out to be much easier than expected, and much easier than converting from an array based approach to a record selection approach would have been. The collection listbox that was crashing was also in a subform. I did not think that was important, but it may have contributed to the failure when highlighting records. The subform was unnecessary, as was using collections for this purpose, and abandoning those two approaches has resolved the crashing and some performance issues. The 40k example was a stress testing step. Most lists should be very much smaller, and cueing the user with a visual highlight will be more practical. Thanks to the way 4D implemented the Highlight Set in the past, highlighting has been a very useful tool that seemed to have no cost. Thanks, Keith - CDI > On Apr 16, 2019, at 11:58 PM, JPR via 4D_Tech <4d_tech@lists.4d.com> wrote: > > [JPR] > > Hi Keith, > > a) It seems that there is some fuzziness in the way Entity Selections and > Collections are understood. Let's try to make it more precise: > > - An Entity selection doesn't 'contain' the Entities, it's a List of Entity > References (in this case, a reference is a 4D internal référence on the > Record which is referenced by the Entity) > > - A Collection has to fit in memory, for each element is a memory object > contained (if scalar) or referenced (if not scalar) by the corresponding > Collection Element. > > During the WT2019, I've demonstrated (1st day), and explained (2nd day) that > you can mix these notions into Collections of entity references (for > instance). > > b) The best way to Highlight elements in a ListBox is LISTBOX SELECT > ROW(*;"listBox";0;lk add to selection)! If it crashes 4D when the listbox > contains a large number of lines, it's a bug. > > c) If the listbox contains a large number of lines, I wonder why it would be > necessary to highlight all, for highlighting is just for UI...(But this is > just a remark ;-) > > Anyway, from the feedback I got from the East part of the WT in US, it seems > that you may find an interest to come to one of the next events, and get some > more information about how it works, and why it works like this, and how to > choose the best technique without playing Blind Man's Bluff with ORDA. We are > here (the Team and myself) to share all the experience we acquired by > exploring and opening up the different paths. > > Anyway, the first day is for free, you will see many technical demos, and a > glance on the future, on the evolution of 4D and what's coming next, you will > get a lot of demos and source code, and also lunch and coffee! > > And if you find it interesting enough,if you think that you still have > something useful to learn, if you feel that you are not yet at the top of > your capabilities, you can then register for the second day, where we dive > deeply into the code and techniques. We will try to answer your questions, we > will do our best to illuminate the road of men who have become lost in their > code, and (like it did for most of the previous attendees), it will save you > a precious and valuable time when you'll be back home. > > I hope to meet you in Austin, Seattle, or San José! > > My very best, > > JPR > >> On 16 Apr 2019, at 17:49, 4d_tech-requ...@lists.4d.com wrote: >> >> I'm looking for a fast way to highlight a selection of rows in an entity >> selection listbox. The way I am aware of works OK unless the listbox gets a >> large number of rows. >> >> Adding records to the Selected Items name in the Property list does not >> highlight the listbox contents. The equivalent of adding records to the >> "UserSet" is not available with entity selection listboxes. >> >> Highlighting all with LISTBOX SELECT ROW(*;"listBox";0;lk add to selection) >> crashes 4D if the listbox contains enough records. >> LISTBOX SELECT ROW(*;"listBox";$position;lk add to selection) crashes if put >> in a fast FOR loop. If the loop is executed more slowly there is success. >> The slowness comes from looking for entitySelected[i] within the entity >> selection and highlighting its position in the listbox. >> >> Is there a better way to get there? > ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: Fast way to highlight a listbox entity selection
[JPR] Hi Keith, a) It seems that there is some fuzziness in the way Entity Selections and Collections are understood. Let's try to make it more precise: - An Entity selection doesn't 'contain' the Entities, it's a List of Entity References (in this case, a reference is a 4D internal référence on the Record which is referenced by the Entity) - A Collection has to fit in memory, for each element is a memory object contained (if scalar) or referenced (if not scalar) by the corresponding Collection Element. During the WT2019, I've demonstrated (1st day), and explained (2nd day) that you can mix these notions into Collections of entity references (for instance). b) The best way to Highlight elements in a ListBox is LISTBOX SELECT ROW(*;"listBox";0;lk add to selection)! If it crashes 4D when the listbox contains a large number of lines, it's a bug. c) If the listbox contains a large number of lines, I wonder why it would be necessary to highlight all, for highlighting is just for UI...(But this is just a remark ;-) Anyway, from the feedback I got from the East part of the WT in US, it seems that you may find an interest to come to one of the next events, and get some more information about how it works, and why it works like this, and how to choose the best technique without playing Blind Man's Bluff with ORDA. We are here (the Team and myself) to share all the experience we acquired by exploring and opening up the different paths. Anyway, the first day is for free, you will see many technical demos, and a glance on the future, on the evolution of 4D and what's coming next, you will get a lot of demos and source code, and also lunch and coffee! And if you find it interesting enough,if you think that you still have something useful to learn, if you feel that you are not yet at the top of your capabilities, you can then register for the second day, where we dive deeply into the code and techniques. We will try to answer your questions, we will do our best to illuminate the road of men who have become lost in their code, and (like it did for most of the previous attendees), it will save you a precious and valuable time when you'll be back home. I hope to meet you in Austin, Seattle, or San José! My very best, JPR > On 16 Apr 2019, at 17:49, 4d_tech-requ...@lists.4d.com wrote: > > I'm looking for a fast way to highlight a selection of rows in an entity > selection listbox. The way I am aware of works OK unless the listbox gets a > large number of rows. > > Adding records to the Selected Items name in the Property list does not > highlight the listbox contents. The equivalent of adding records to the > "UserSet" is not available with entity selection listboxes. > > Highlighting all with LISTBOX SELECT ROW(*;"listBox";0;lk add to selection) > crashes 4D if the listbox contains enough records. > LISTBOX SELECT ROW(*;"listBox";$position;lk add to selection) crashes if put > in a fast FOR loop. If the loop is executed more slowly there is success. > The slowness comes from looking for entitySelected[i] within the entity > selection and highlighting its position in the listbox. > > Is there a better way to get there? ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: Fast way to highlight a listbox entity selection
Bingo. On Tue, Apr 16, 2019 at 11:53 AM Keith Culotta via 4D_Tech < 4d_tech@lists.4d.com> wrote: > It's looking like it can all be done with entity selections, and be more > efficient. > -- Kirk Brooks San Francisco, CA === What can be said, can be said clearly, and what you can’t say, you should shut up about *Wittgenstein and the Computer * ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: Fast way to highlight a listbox entity selection
Kirk, Interesting stuff, especially how entitySelection.toCollection duplicates data. I'm currently displaying collections in the listbox. It's looking like it can all be done with entity selections, and be more efficient. Thanks, Keith - CDI > On Apr 16, 2019, at 12:53 PM, Kirk Brooks via 4D_Tech <4d_tech@lists.4d.com> > wrote: > > Keith, > You know you can go about this from another point of view. I actually > posted about this a bit ago. This won't accomplish exactly what you are > asking for but it may be something you can use. > > First, remember that even when you have a very large collection or entity > selection, as you seem to, you can make references to it WITHOUT > duplicating it. This saves memory, obviously, but also means you can work > with the list without having to worry about syncing it. It's even better > when you are working with an entity collection. With 'lazy loading' the > collection only contains references to the entities not a full copy of the > data. > > Next, if it's the case the highlighted elements are being generated by some > sort of filter or search perhaps you can accomplish your goal by only > showing the records that match whatever criteria you have. I would think > this is especially true with a list of 40K items. Personally I would really > not want to have to scroll down to the second item highlighted when it's > #37306. > > So, you have your 40k entity selection. The trick is not to put this in the > listbox. Instead make a reference to it and display that. Remember neither > of these entity selections consists of the data and the second one, the one > in the listbox, is only a reference to the first. I learned from JPR that > this is very memory efficient. > > Let's say you put the entity selection in a process var (I would most > likely use Form for this) but to simplify the example let's call it > 'entitySelection'. Next make a collection on Form called > "displayCollection" (or whatever) as > > > Form.displayCollection:=entitySelection > > Use Form.displayCollection in the listbox. By default the listbox shows all > the elements of entitySelection. > > To show a selection of this list you could do: > > Form.displayCollection:=entitySelection.query("dateHired < :1";(Current > date-90)) //borrowing a query example from the docs. > Form.displayCollection:=Form.displayCollection // forces the listbox to > update itself > > > What are we doing? The query on the entity selection returns a collection. > The contents of the collection are references to the respective elements in > entitySelection. We're putting the query result into Form.displayCollection > and since we have defined our listbox to use displayCollection the listbox > now contains the query result. > > This is very fast. Like update while the user is typing fast. And since we > are working with references changes you make to the something in the > listbox populates back to the entity selection, entitySelection. Plus it's > memory efficient. > > Another thing I learned at the WT - the entitySelection.toCollection > command can be helpful BUT it does move the actual entity data to the > collection. For something like a 40k element entity selection this might > matter. So be sure to stick with your entity selection when it's large. And > in this case the data would be in entitySelection but not in the references > to it. > > > On Tue, Apr 16, 2019 at 9:11 AM Keith Culotta via 4D_Tech < > 4d_tech@lists.4d.com> wrote: > >> Douglas, >> >> That seems promising. Since the listbox is a collection/entity selection, >> each row's color would be set by the rows presence in the "Selected items" >> collection. I imagine the performance would be OK as long as the search >> only took place as the row becomes visible to the User. >> >> Kirk's proposal alludes to a solution that 4D seems inches away from, >> where a row's membership in the selected items collection automatically >> grants it a highlight, similar to the boolean array of the array based >> listbox, and the HighlightSet of the selection based listbox. >> >> Thanks, >> Keith - CDI >> >>> On Apr 16, 2019, at 10:44 AM, Douglas von Roeder via 4D_Tech < >> 4d_tech@lists.4d.com> wrote: >>> >>> Keith: >>> >>> How about this - rather than change the highlight, what about just >> changing >>> the color of the rows to mimic that they’re selected? You can still >>> maintain array of record numbers/ID’s that represent the selection but >> just >>> update the UI so that it looks like the rows are selected. >>> >>> My thinking is that by using the list box code to select the rows, that’s >>> causing 4D to reload the records. The thought "Why would you want to do >>> that (if you don’t have to)?”, comes to mind. :-) >>> >>> -- >>> Douglas von Roeder >>> 949-336-2902 >>> >>> >>> On Tue, Apr 16, 2019 at 7:22 AM Keith Culotta via 4D_Tech < >>> 4d_tech@lists.4d.com> wrote: >>> Justin, Thank you for the suggestion.
Re: Fast way to highlight a listbox entity selection
Keith, You know you can go about this from another point of view. I actually posted about this a bit ago. This won't accomplish exactly what you are asking for but it may be something you can use. First, remember that even when you have a very large collection or entity selection, as you seem to, you can make references to it WITHOUT duplicating it. This saves memory, obviously, but also means you can work with the list without having to worry about syncing it. It's even better when you are working with an entity collection. With 'lazy loading' the collection only contains references to the entities not a full copy of the data. Next, if it's the case the highlighted elements are being generated by some sort of filter or search perhaps you can accomplish your goal by only showing the records that match whatever criteria you have. I would think this is especially true with a list of 40K items. Personally I would really not want to have to scroll down to the second item highlighted when it's #37306. So, you have your 40k entity selection. The trick is not to put this in the listbox. Instead make a reference to it and display that. Remember neither of these entity selections consists of the data and the second one, the one in the listbox, is only a reference to the first. I learned from JPR that this is very memory efficient. Let's say you put the entity selection in a process var (I would most likely use Form for this) but to simplify the example let's call it 'entitySelection'. Next make a collection on Form called "displayCollection" (or whatever) as Form.displayCollection:=entitySelection Use Form.displayCollection in the listbox. By default the listbox shows all the elements of entitySelection. To show a selection of this list you could do: Form.displayCollection:=entitySelection.query("dateHired < :1";(Current date-90)) //borrowing a query example from the docs. Form.displayCollection:=Form.displayCollection // forces the listbox to update itself What are we doing? The query on the entity selection returns a collection. The contents of the collection are references to the respective elements in entitySelection. We're putting the query result into Form.displayCollection and since we have defined our listbox to use displayCollection the listbox now contains the query result. This is very fast. Like update while the user is typing fast. And since we are working with references changes you make to the something in the listbox populates back to the entity selection, entitySelection. Plus it's memory efficient. Another thing I learned at the WT - the entitySelection.toCollection command can be helpful BUT it does move the actual entity data to the collection. For something like a 40k element entity selection this might matter. So be sure to stick with your entity selection when it's large. And in this case the data would be in entitySelection but not in the references to it. On Tue, Apr 16, 2019 at 9:11 AM Keith Culotta via 4D_Tech < 4d_tech@lists.4d.com> wrote: > Douglas, > > That seems promising. Since the listbox is a collection/entity selection, > each row's color would be set by the rows presence in the "Selected items" > collection. I imagine the performance would be OK as long as the search > only took place as the row becomes visible to the User. > > Kirk's proposal alludes to a solution that 4D seems inches away from, > where a row's membership in the selected items collection automatically > grants it a highlight, similar to the boolean array of the array based > listbox, and the HighlightSet of the selection based listbox. > > Thanks, > Keith - CDI > > > On Apr 16, 2019, at 10:44 AM, Douglas von Roeder via 4D_Tech < > 4d_tech@lists.4d.com> wrote: > > > > Keith: > > > > How about this - rather than change the highlight, what about just > changing > > the color of the rows to mimic that they’re selected? You can still > > maintain array of record numbers/ID’s that represent the selection but > just > > update the UI so that it looks like the rows are selected. > > > > My thinking is that by using the list box code to select the rows, that’s > > causing 4D to reload the records. The thought "Why would you want to do > > that (if you don’t have to)?”, comes to mind. :-) > > > > -- > > Douglas von Roeder > > 949-336-2902 > > > > > > On Tue, Apr 16, 2019 at 7:22 AM Keith Culotta via 4D_Tech < > > 4d_tech@lists.4d.com> wrote: > > > >> Justin, > >> > >> Thank you for the suggestion. > >> > >> I switched the deselect-all code to > >> LISTBOX SELECT ROW(*;"valsBox";1;lk replace selection) > >> LISTBOX SELECT ROW(*;"valsBox";1;lk remove from selection) > >> and the selection did clear, however as soon as this add-to-selection > code > >> is executed > >> LISTBOX SELECT ROW(*;"valsBox";0;lk replace selection) > >> 4D immediately crashes. > >> > >> If all 40k rows get deselected, using either method, and selecting them > >> all again is done in a loop, the loop finishes in about two se
Re: Fast way to highlight a listbox entity selection
Douglas, That seems promising. Since the listbox is a collection/entity selection, each row's color would be set by the rows presence in the "Selected items" collection. I imagine the performance would be OK as long as the search only took place as the row becomes visible to the User. Kirk's proposal alludes to a solution that 4D seems inches away from, where a row's membership in the selected items collection automatically grants it a highlight, similar to the boolean array of the array based listbox, and the HighlightSet of the selection based listbox. Thanks, Keith - CDI > On Apr 16, 2019, at 10:44 AM, Douglas von Roeder via 4D_Tech > <4d_tech@lists.4d.com> wrote: > > Keith: > > How about this - rather than change the highlight, what about just changing > the color of the rows to mimic that they’re selected? You can still > maintain array of record numbers/ID’s that represent the selection but just > update the UI so that it looks like the rows are selected. > > My thinking is that by using the list box code to select the rows, that’s > causing 4D to reload the records. The thought "Why would you want to do > that (if you don’t have to)?”, comes to mind. :-) > > -- > Douglas von Roeder > 949-336-2902 > > > On Tue, Apr 16, 2019 at 7:22 AM Keith Culotta via 4D_Tech < > 4d_tech@lists.4d.com> wrote: > >> Justin, >> >> Thank you for the suggestion. >> >> I switched the deselect-all code to >> LISTBOX SELECT ROW(*;"valsBox";1;lk replace selection) >> LISTBOX SELECT ROW(*;"valsBox";1;lk remove from selection) >> and the selection did clear, however as soon as this add-to-selection code >> is executed >> LISTBOX SELECT ROW(*;"valsBox";0;lk replace selection) >> 4D immediately crashes. >> >> If all 40k rows get deselected, using either method, and selecting them >> all again is done in a loop, the loop finishes in about two seconds. >> At that point the macOS spinning wheel appears for three minutes. The >> highlight then appears and control is returned to the app. >> The fewer the records being highlighted, the shorter the macOS wheel spins. >> >> Regards, >> Keith - CDI >> >>> On Apr 15, 2019, at 7:50 PM, Justin Carr via 4D_Tech < >> 4d_tech@lists.4d.com> wrote: >>> >>> On 16 Apr 2019, at 5:04 am, Keith Culotta via 4D_Tech < >> 4d_tech@lists.4d.com> wrote: Hello, I'm looking for a fast way to highlight a selection of rows in an >> entity selection listbox. The way I am aware of works OK unless the >> listbox gets a large number of rows. Adding records to the Selected Items name in the Property list does not >> highlight the listbox contents. The equivalent of adding records to the >> "UserSet" is not available with entity selection listboxes. Highlighting all with LISTBOX SELECT ROW(*;"listBox";0;lk add to >> selection) crashes 4D if the listbox contains enough records. LISTBOX SELECT ROW(*;"listBox";$position;lk add to selection) crashes >> if put in a fast FOR loop. If the loop is executed more slowly there is >> success. The slowness comes from looking for entitySelected[i] within the >> entity selection and highlighting its position in the listbox. Is there a better way to get there? >>> >>> Hey Keith >>> >>> Are you clearing the listbox selection first (with LISTBOX SELECT >> ROW(*;"listBox";0;lk remove from selection)? If so, that is probably the >> cause of the crashing you are seeing. You can workaround it by highlighting >> and unhighlighting the first row instead, i.e. >>> >>> LISTBOX SELECT ROW(*;"listBox";1;lk replace selection) >>> LISTBOX SELECT ROW(*;"listBox";1;lk remove from selection) >>> >>> cheers >>> Justin >> >> ** >> 4D Internet Users Group (4D iNUG) >> Archive: http://lists.4d.com/archives.html >> Options: https://lists.4d.com/mailman/options/4d_tech >> Unsub: mailto:4d_tech-unsubscr...@lists.4d.com >> ** > ** > 4D Internet Users Group (4D iNUG) > Archive: http://lists.4d.com/archives.html > Options: https://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > ** ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: Fast way to highlight a listbox entity selection
All, I just started a Feature Request for this: http://forums.4d.com/Post//29409213/1/ Take a look and see what you think. Collection/entity based listboxes are a very different animal from array or selection based ones. And the way to work with them is different too. Frankly the easiest thing would be if we could set the selected collection and the listbox would highlight the rows corresponding to those elements. I'm proposing a command where you pass a collection of indices (scalar, the index values of the objects you want) or a collection of elements contained in the listbox collection. This second form is what you get with collection.query. On Tue, Apr 16, 2019 at 8:45 AM Douglas von Roeder via 4D_Tech < 4d_tech@lists.4d.com> wrote: > Keith: > > How about this - rather than change the highlight, what about just changing > the color of the rows to mimic that they’re selected? You can still > maintain array of record numbers/ID’s that represent the selection but just > update the UI so that it looks like the rows are selected. > > My thinking is that by using the list box code to select the rows, that’s > causing 4D to reload the records. The thought "Why would you want to do > that (if you don’t have to)?”, comes to mind. :-) > > -- > Douglas von Roeder > 949-336-2902 > > > On Tue, Apr 16, 2019 at 7:22 AM Keith Culotta via 4D_Tech < > 4d_tech@lists.4d.com> wrote: > > > Justin, > > > > Thank you for the suggestion. > > > > I switched the deselect-all code to > >LISTBOX SELECT ROW(*;"valsBox";1;lk replace selection) > >LISTBOX SELECT ROW(*;"valsBox";1;lk remove from selection) > > and the selection did clear, however as soon as this add-to-selection > code > > is executed > >LISTBOX SELECT ROW(*;"valsBox";0;lk replace selection) > > 4D immediately crashes. > > > > If all 40k rows get deselected, using either method, and selecting them > > all again is done in a loop, the loop finishes in about two seconds. > > At that point the macOS spinning wheel appears for three minutes. The > > highlight then appears and control is returned to the app. > > The fewer the records being highlighted, the shorter the macOS wheel > spins. > > > > Regards, > > Keith - CDI > > > > > On Apr 15, 2019, at 7:50 PM, Justin Carr via 4D_Tech < > > 4d_tech@lists.4d.com> wrote: > > > > > > On 16 Apr 2019, at 5:04 am, Keith Culotta via 4D_Tech < > > 4d_tech@lists.4d.com> wrote: > > >> > > >> Hello, > > >> > > >> I'm looking for a fast way to highlight a selection of rows in an > > entity selection listbox. The way I am aware of works OK unless the > > listbox gets a large number of rows. > > >> > > >> Adding records to the Selected Items name in the Property list does > not > > highlight the listbox contents. The equivalent of adding records to the > > "UserSet" is not available with entity selection listboxes. > > >> > > >> Highlighting all with LISTBOX SELECT ROW(*;"listBox";0;lk add to > > selection) crashes 4D if the listbox contains enough records. > > >> LISTBOX SELECT ROW(*;"listBox";$position;lk add to selection) crashes > > if put in a fast FOR loop. If the loop is executed more slowly there is > > success. The slowness comes from looking for entitySelected[i] within > the > > entity selection and highlighting its position in the listbox. > > >> > > >> Is there a better way to get there? > > > > > > Hey Keith > > > > > > Are you clearing the listbox selection first (with LISTBOX SELECT > > ROW(*;"listBox";0;lk remove from selection)? If so, that is probably the > > cause of the crashing you are seeing. You can workaround it by > highlighting > > and unhighlighting the first row instead, i.e. > > > > > > LISTBOX SELECT ROW(*;"listBox";1;lk replace selection) > > > LISTBOX SELECT ROW(*;"listBox";1;lk remove from selection) > > > > > > cheers > > > Justin > > > > ** > > 4D Internet Users Group (4D iNUG) > > Archive: http://lists.4d.com/archives.html > > Options: https://lists.4d.com/mailman/options/4d_tech > > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > > ** > ** > 4D Internet Users Group (4D iNUG) > Archive: http://lists.4d.com/archives.html > Options: https://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > ** -- Kirk Brooks San Francisco, CA === What can be said, can be said clearly, and what you can’t say, you should shut up about *Wittgenstein and the Computer * ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com *
Re: Fast way to highlight a listbox entity selection
Checking the listbox's Property "Hide extra blank rows" stopped 4D from unexpectedly quitting when using LISTBOX SELECT ROW(*;"valsBox";0;lk replace selection) // and it's fast or just having a lot of rows to highlight in a loop. The crashing showed up more often in compiled mode before the change. Still have the spinning wheel however. Keith - CDI > On Apr 16, 2019, at 9:22 AM, Keith Culotta via 4D_Tech <4d_tech@lists.4d.com> > wrote: > > Justin, > > Thank you for the suggestion. > > I switched the deselect-all code to > LISTBOX SELECT ROW(*;"valsBox";1;lk replace selection) > LISTBOX SELECT ROW(*;"valsBox";1;lk remove from selection) > and the selection did clear, however as soon as this add-to-selection code is > executed > LISTBOX SELECT ROW(*;"valsBox";0;lk replace selection) > 4D immediately crashes. > > If all 40k rows get deselected, using either method, and selecting them all > again is done in a loop, the loop finishes in about two seconds. > At that point the macOS spinning wheel appears for three minutes. The > highlight then appears and control is returned to the app. > The fewer the records being highlighted, the shorter the macOS wheel spins. > > Regards, > Keith - CDI > >> On Apr 15, 2019, at 7:50 PM, Justin Carr via 4D_Tech <4d_tech@lists.4d.com> >> wrote: >> >> On 16 Apr 2019, at 5:04 am, Keith Culotta via 4D_Tech <4d_tech@lists.4d.com> >> wrote: >>> >>> Hello, >>> >>> I'm looking for a fast way to highlight a selection of rows in an entity >>> selection listbox. The way I am aware of works OK unless the listbox gets >>> a large number of rows. >>> >>> Adding records to the Selected Items name in the Property list does not >>> highlight the listbox contents. The equivalent of adding records to the >>> "UserSet" is not available with entity selection listboxes. >>> >>> Highlighting all with LISTBOX SELECT ROW(*;"listBox";0;lk add to selection) >>> crashes 4D if the listbox contains enough records. >>> LISTBOX SELECT ROW(*;"listBox";$position;lk add to selection) crashes if >>> put in a fast FOR loop. If the loop is executed more slowly there is >>> success. The slowness comes from looking for entitySelected[i] within the >>> entity selection and highlighting its position in the listbox. >>> >>> Is there a better way to get there? >> >> Hey Keith >> >> Are you clearing the listbox selection first (with LISTBOX SELECT >> ROW(*;"listBox";0;lk remove from selection)? If so, that is probably the >> cause of the crashing you are seeing. You can workaround it by highlighting >> and unhighlighting the first row instead, i.e. >> >> LISTBOX SELECT ROW(*;"listBox";1;lk replace selection) >> LISTBOX SELECT ROW(*;"listBox";1;lk remove from selection) >> >> cheers >> Justin > > ** > 4D Internet Users Group (4D iNUG) > Archive: http://lists.4d.com/archives.html > Options: https://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > ** ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: Fast way to highlight a listbox entity selection
Keith: How about this - rather than change the highlight, what about just changing the color of the rows to mimic that they’re selected? You can still maintain array of record numbers/ID’s that represent the selection but just update the UI so that it looks like the rows are selected. My thinking is that by using the list box code to select the rows, that’s causing 4D to reload the records. The thought "Why would you want to do that (if you don’t have to)?”, comes to mind. :-) -- Douglas von Roeder 949-336-2902 On Tue, Apr 16, 2019 at 7:22 AM Keith Culotta via 4D_Tech < 4d_tech@lists.4d.com> wrote: > Justin, > > Thank you for the suggestion. > > I switched the deselect-all code to >LISTBOX SELECT ROW(*;"valsBox";1;lk replace selection) >LISTBOX SELECT ROW(*;"valsBox";1;lk remove from selection) > and the selection did clear, however as soon as this add-to-selection code > is executed >LISTBOX SELECT ROW(*;"valsBox";0;lk replace selection) > 4D immediately crashes. > > If all 40k rows get deselected, using either method, and selecting them > all again is done in a loop, the loop finishes in about two seconds. > At that point the macOS spinning wheel appears for three minutes. The > highlight then appears and control is returned to the app. > The fewer the records being highlighted, the shorter the macOS wheel spins. > > Regards, > Keith - CDI > > > On Apr 15, 2019, at 7:50 PM, Justin Carr via 4D_Tech < > 4d_tech@lists.4d.com> wrote: > > > > On 16 Apr 2019, at 5:04 am, Keith Culotta via 4D_Tech < > 4d_tech@lists.4d.com> wrote: > >> > >> Hello, > >> > >> I'm looking for a fast way to highlight a selection of rows in an > entity selection listbox. The way I am aware of works OK unless the > listbox gets a large number of rows. > >> > >> Adding records to the Selected Items name in the Property list does not > highlight the listbox contents. The equivalent of adding records to the > "UserSet" is not available with entity selection listboxes. > >> > >> Highlighting all with LISTBOX SELECT ROW(*;"listBox";0;lk add to > selection) crashes 4D if the listbox contains enough records. > >> LISTBOX SELECT ROW(*;"listBox";$position;lk add to selection) crashes > if put in a fast FOR loop. If the loop is executed more slowly there is > success. The slowness comes from looking for entitySelected[i] within the > entity selection and highlighting its position in the listbox. > >> > >> Is there a better way to get there? > > > > Hey Keith > > > > Are you clearing the listbox selection first (with LISTBOX SELECT > ROW(*;"listBox";0;lk remove from selection)? If so, that is probably the > cause of the crashing you are seeing. You can workaround it by highlighting > and unhighlighting the first row instead, i.e. > > > > LISTBOX SELECT ROW(*;"listBox";1;lk replace selection) > > LISTBOX SELECT ROW(*;"listBox";1;lk remove from selection) > > > > cheers > > Justin > > ** > 4D Internet Users Group (4D iNUG) > Archive: http://lists.4d.com/archives.html > Options: https://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > ** ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: Fast way to highlight a listbox entity selection
Justin, Thank you for the suggestion. I switched the deselect-all code to LISTBOX SELECT ROW(*;"valsBox";1;lk replace selection) LISTBOX SELECT ROW(*;"valsBox";1;lk remove from selection) and the selection did clear, however as soon as this add-to-selection code is executed LISTBOX SELECT ROW(*;"valsBox";0;lk replace selection) 4D immediately crashes. If all 40k rows get deselected, using either method, and selecting them all again is done in a loop, the loop finishes in about two seconds. At that point the macOS spinning wheel appears for three minutes. The highlight then appears and control is returned to the app. The fewer the records being highlighted, the shorter the macOS wheel spins. Regards, Keith - CDI > On Apr 15, 2019, at 7:50 PM, Justin Carr via 4D_Tech <4d_tech@lists.4d.com> > wrote: > > On 16 Apr 2019, at 5:04 am, Keith Culotta via 4D_Tech <4d_tech@lists.4d.com> > wrote: >> >> Hello, >> >> I'm looking for a fast way to highlight a selection of rows in an entity >> selection listbox. The way I am aware of works OK unless the listbox gets a >> large number of rows. >> >> Adding records to the Selected Items name in the Property list does not >> highlight the listbox contents. The equivalent of adding records to the >> "UserSet" is not available with entity selection listboxes. >> >> Highlighting all with LISTBOX SELECT ROW(*;"listBox";0;lk add to selection) >> crashes 4D if the listbox contains enough records. >> LISTBOX SELECT ROW(*;"listBox";$position;lk add to selection) crashes if put >> in a fast FOR loop. If the loop is executed more slowly there is success. >> The slowness comes from looking for entitySelected[i] within the entity >> selection and highlighting its position in the listbox. >> >> Is there a better way to get there? > > Hey Keith > > Are you clearing the listbox selection first (with LISTBOX SELECT > ROW(*;"listBox";0;lk remove from selection)? If so, that is probably the > cause of the crashing you are seeing. You can workaround it by highlighting > and unhighlighting the first row instead, i.e. > > LISTBOX SELECT ROW(*;"listBox";1;lk replace selection) > LISTBOX SELECT ROW(*;"listBox";1;lk remove from selection) > > cheers > Justin ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: Fast way to highlight a listbox entity selection
On 16 Apr 2019, at 5:04 am, Keith Culotta via 4D_Tech <4d_tech@lists.4d.com> wrote: > > Hello, > > I'm looking for a fast way to highlight a selection of rows in an entity > selection listbox. The way I am aware of works OK unless the listbox gets a > large number of rows. > > Adding records to the Selected Items name in the Property list does not > highlight the listbox contents. The equivalent of adding records to the > "UserSet" is not available with entity selection listboxes. > > Highlighting all with LISTBOX SELECT ROW(*;"listBox";0;lk add to selection) > crashes 4D if the listbox contains enough records. > LISTBOX SELECT ROW(*;"listBox";$position;lk add to selection) crashes if put > in a fast FOR loop. If the loop is executed more slowly there is success. > The slowness comes from looking for entitySelected[i] within the entity > selection and highlighting its position in the listbox. > > Is there a better way to get there? Hey Keith Are you clearing the listbox selection first (with LISTBOX SELECT ROW(*;"listBox";0;lk remove from selection)? If so, that is probably the cause of the crashing you are seeing. You can workaround it by highlighting and unhighlighting the first row instead, i.e. LISTBOX SELECT ROW(*;"listBox";1;lk replace selection) LISTBOX SELECT ROW(*;"listBox";1;lk remove from selection) cheers Justin ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **