Page 1 of 1

LISTBROWSER_Top

Posted: Thu Apr 26, 2018 11:41 pm
by mritter0
In my program Workbench Explorer sometimes I need to set the top item in the list. Normally when scan a drawer it is set to 0. But, say you have scrolled down 10 lines with the mouse wheel, then hit reload. I check what the _Top is first, rescan drawer, update the list (detach it, free old, build new), then attach it and set LISTBROWSER_Top, LBTop,. But it does not always work correctly. I can't figure out why.

This code works with 2 of the 4 situations I have.

Code: Select all

	ILayout->SetPageGadgetAttrs((struct Gadget *)Objects[GAD_CONTENT],Objects[GAD_CF_PAGES_CONTENT],MainWindow,NULL,
		LISTBROWSER_ColumnInfo,				WhichCI,
		LISTBROWSER_SortColumn,				SortColumn,
		LISTBROWSER_VertSeparators,			ShowVertSeparators,
		LISTBROWSER_AutoFit,				Prefs->AutoFitColumns,
		LISTBROWSER_Labels,					lblist2,
		LISTBROWSER_Top,					LBTop,
	TAG_DONE);
If I swap the last 2 lines, it works with 1 other but then first 2 no longer work. One situation never works. I know LBTop value is correct, I Printf() before attaching the list to see it.

I have played around with _Top and _Labels order, used SetAttrs() instead (yes, the gadget is on a page.gadget). LBTop will be set to 0, scan a drawer, but will start at the old LBTop spot. No rhyme or reason sometimes.

I would think you would set _Top first, then _Labels. Is there some magic order I am not doing? Does it even matter what order? Just baffling me.

listbrowser.gadget 53.74 (23.10.2016)

Re: LISTBROWSER_Top

Posted: Fri Apr 27, 2018 1:08 am
by broadblues
Try calling RefreshPageGadget() after re-adding the list and setting LISTBROWSER_Top.

Always set LISTBROWSER_Top after adding the list, it's not meaningfull if no list is attached,

Possibly use a seperate call to SetPageGadgetAttrs.


Code: Select all

   ILayout->SetPageGadgetAttrs((struct Gadget *)Objects[GAD_CONTENT],Objects[GAD_CF_PAGES_CONTENT],MainWindow,NULL,
      LISTBROWSER_ColumnInfo,            WhichCI,
      LISTBROWSER_SortColumn,            SortColumn,
      LISTBROWSER_VertSeparators,         ShowVertSeparators,
      LISTBROWSER_AutoFit,            Prefs->AutoFitColumns,
      LISTBROWSER_Labels,               lblist2,
   TAG_DONE);

   ILayout->SetPageGadgetAttrs((struct Gadget *)Objects[GAD_CONTENT],Objects[GAD_CF_PAGES_CONTENT],MainWindow,NULL,
          LISTBROWSER_Top,               LBTop,
   TAG_DONE);

ILayout->RefreshPageGadget((struct Gadget *)Objects[GAD_CONTENT],Objects[GAD_CF_PAGES_CONTENT],MainWindow,NULL,;

Ought to give consistant results.


AS an aside do you really need to set all those other attrs when you reattache the list (fine if they have changed, but wasteful if they didn't);

Re: LISTBROWSER_Top

Posted: Fri Apr 27, 2018 11:13 pm
by mritter0
I made it work with the 2 separate calls, and a small change where list is detached. Slight little flicker as it adjusts, but I can live with it.

Re: LISTBROWSER_Top

Posted: Sat Apr 28, 2018 2:00 am
by broadblues
Not sure if I mentioned this in any previous post but you can reduce flicker when chnaging lists but removing it with SetAttrs() and only using SteGadgetAttrs() or equiv when you reattach the list.

Re: LISTBROWSER_Top

Posted: Sat Apr 28, 2018 2:26 am
by mritter0
That was the issue I was having. I did it with 2 calls way back when, but not using SetAttrs() to detach, so it still flickered. Figured it out over time. Wish I knew earlier........