cancel
Showing results for 
Search instead for 
Did you mean: 

How to detect Release of item of scrolllist ?

EEuge
Senior

I want work with scrolllist this way: touching and dragging -> scrolling the list of files, pressing (without drag) and releasing -> go to directory after releasing.

Question: how can i get Release event? Scrollist has onle 2 events - setItemSelectedCallback and setItemPressedCallback

9 REPLIES 9
MM..1
Chief II

Try read this Workaround for swipe containers not swiping if dragged on a button within (st.com)

Or simpiy you need activate onclicklistener maybe not release

Problem.....

If I create more than 9 files - system halts when I scroll list DOWN.

The program halts during the execution of scrollList1UpdateItem() that is called for no apparent reason. is this normal? I don't update the elements, but for some reason when scrolling down scrollList1UpdateItem is called.

Should it be called while scrollin DOWN?

scrollList1UpdateItem is called by system on every changes and need be writed as i show, reflect all values in itemIndex.

Please read how scrollist class work in reference ScrollList | TouchGFX Documentation

Hmm.. I didn't know, that scrollList1UpdateItem is called not for all items, but only for currently visible. If I scroll down, and new item must be shown, scrollList1UpdateItem called for it...

I found course of problem, but I don't know how fix...

Look...

I have scrollist with 8 visible items and 15 total items.

I change background of item when it pressed:

void STORAGE_SCREENView::scrollList1ItemPressedHandler(int16_t itemIndex)
{
	(*FileList_Container*)scrollList1ListItems.getDrawable(itemPressed_old)).HighLightItem(false);
(*(FileList_Container*)scrollList1ListItems.getDrawable(itemIndex)).HighLightItem(true);
 
itemPressed_old=itemIndex;
 if (itemIndex>2)
 {
  itemPressed_old=itemIndex;
 }	
}

if I delete strings

(*FileList_Container*)scrollList1ListItems.getDrawable(itemPressed_old)).HighLightItem(false);
(*(FileList_Container*)scrollList1ListItems.getDrawable(itemIndex)).HighLightItem(true);

problem disappears, if these strings a present, the problem (halt of system) is present too.

In "void STORAGE_SCREENView::scrollList1UpdateItem(FileList_Container& item, int16_t itemIndex)" all are simply - I can write "item.SetParam...."

But in void STORAGE_SCREENView::scrollList1ItemPressedHandler(int16_t itemIndex) I can't write "item", I need write (*(FileList_Container*)scrollList1ListItems.getDrawable(itemPressed_old)).HighLightItem(false);

How can I choose item to give with him "HighlightItem()" ?

How can I get link (pointer, handler) to Item, not only it itemIndex?

stop use getDrawable , this isnt right way to work with objects in list.

All changes you need do in update function and in others you need call

	sel=false;
	scrollList1.itemChanged(itemPressed_old);
 
       sel=true;
      scrollList1.itemChanged(itemIndex);

itemChanged force call STORAGE_SCREENView::scrollList1UpdateItem , and here you call

item.HighLightItem(sel);

Good... System don't halts.

But

item.HighLightItem(sel);

is called every time when UpdateItem is called, even without itemChanged(itemIndex) (without pressed event)

Hm..... may be I must to set number of selected Item, when scrollList1ItemPressedHandler() is called, and check it in scrollList1UpdateItem()...

I'll try....

Hello! You write

the scrollList1.itemChanged(itemIndex) function does not call scrollList1UpdateItem if the item with the itemIndex number is outside the scroll window. How to fix it?

You maybe mean olditem, because itemIndex is on Display when is clicked or managed. Yes olditem maybe is outside and call to update is skipped, but you need write code with some defaults or bool logic in update and all show as needed when scrolled back.

Thank you, I already guessed it 10 minutes after writing the post