Page 1 of 1

Clear ListBrowser

Posted: Thu Oct 29, 2015 1:55 am
by mritter0
I am not seeing an easy way to clear (remove all text from) a listbrowser. Detaching the list does not clear it. IListBrowser->FreeListBrowserList(lblist2); does not clear it.

The issue I have is my listbrowser ColumnInfo will vary in number of columns depending on what the user is currently doing. So adding back a blank list could be tedious. And more work to then detach that list, clear it, add new real list.

Is there an easy way to detach the list, wipe the gadget display area clean, do some stuff, add a new list when ready?

ClearListBrowserDisplayArea() would be a nice addition.

Re: Clear ListBrowser

Posted: Thu Oct 29, 2015 3:33 am
by tonyw
Without reading the docs, I would guess something like:

Disconnect list
Refresh

or

Disconnect List
Reconnect blank list
Refresh

Re: Clear ListBrowser

Posted: Thu Oct 29, 2015 3:39 pm
by broadblues
mritter0 wrote:I am not seeing an easy way to clear (remove all text from) a listbrowser. Detaching the list does not clear it. IListBrowser->FreeListBrowserList(lblist2); does not clear it.

The issue I have is my listbrowser ColumnInfo will vary in number of columns depending on what the user is currently doing. So adding back a blank list could be tedious. And more work to then detach that list, clear it, add new real list.

Is there an easy way to detach the list, wipe the gadget display area clean, do some stuff, add a new list when ready?

ClearListBrowserDisplayArea() would be a nice addition.
The process should be

Create List
Attach
Refresh (sometime rethink window if layout will chnage)
Detach List
Modify
Reattach List
Refresh (or rethink if list browser may chnage size)

There no need to clear the listbrower whilst modifyig the list. You don;t want it to flicker, just smoothly update from on set of data to the other.

Ofcourse if there is an extended period when you want to display nothing, (no disks inserted for example based on one of your other questions :-) ) you can either not reattach the list before refreshing or attach an empty list and refresh.

eg:

Code: Select all

			ObtainSemaphore(mv->mv_FileListSema);
	    		SetAttrs(mv->mv_Gadgets[MV_GAD_FILELISTER],LISTBROWSER_Labels,NULL,TAG_DONE);	    	
/*

Lots of stuff here that chnages the detached list, perhaps even clears it. 

*/
	    		SetAttrs(mv->mv_Gadgets[MV_GAD_FILELISTER],LISTBROWSER_Labels,&mv->mv_FileList,TAG_DONE);
	    		if(mv->mv_Gadgets[MV_GAD_FILELISTER])
	    		{
			   		SelectNodeAndMakeVisible(mv->mv_Gadgets[MV_GAD_FILELISTER],mv->mv_Window,NULL,(struct Node *)dtd->dtd_CurrentFile);
			   		if(mv->mv_Window)
			   		{
			   			RefreshGList(mv->mv_Gadgets[MV_GAD_FILELISTER],mv->mv_Window,NULL,1);
			   		}
			   	}
			   	ReleaseSemaphore(mv->mv_FileListSema);
You *could* call RefreshSetGadgetAttrs() when removing the list instead of SetAttrs ot StetGadgetsAttrs() but only do that when you *know* your list must be empty for a while and your not simply exchnaging data sets.

Make sure your window pointer is valid before calling that, and NULL is not okay.