B4J Question [Solved]xCustomListView - determine which panel was clicked in item_clicked

Hilton

Active Member
Licensed User
Longtime User
Hi folks,
I am using the clv with the expanding and collapsing items(and enjoying it). However, when an item is in the expanded state showing a form in a pane, I do not want the item to collapse when this pane containing the form is clicked, only when the title panel is clicked.

I have been trying to find out how to determine which panel was clicked in the clv1_ItemClicked Sub so that I can either collapse the item or just ignore the click off the form pane. My detective skills must be somewhat impaired, because I can find nothing to help me within the existing community items.

Any help would be appreciated.
Hilton.
 

mangojack

Well-Known Member
Licensed User
Longtime User
Guaranteed there is a more succinct method to determine which panel (Title or Expanded) was clicked .. I'm curious to see myself .

One option ..

Process Global flag and generate Mouse Clicked events for the Title and Expanded panels ...

B4X:
Private flagTitleClick As Boolean

Sub pnlExpanded_MouseClicked (EventData As MouseEvent)
    flagTitleClick = False
End Sub

Sub pnlTitle_MouseClicked (EventData As MouseEvent)
    flagTitleClick = True
End Sub

Sub clv1_ItemClick (Index As Int, Value As Object)
    Dim p As B4XView = clv1.GetPanel(Index)
    If p.Tag = True Then  '(expanded)
        If flagTitleClick  Then
            CollapseItem(Index)
        End If
    Else
        ExpandItem(Index)
    End If
End Sub
 
Upvote 0

Hilton

Active Member
Licensed User
Longtime User
Thanks for your interest MJ, however, the only mouse event picked up is that of the top container, I guess that events from the contained panels get redirected to the top container. Obviously, any textfields, buttons etc contained in any panel still behave as one would expect. The nuisance is that any click on a sub panel goes to the top level.

I will press on, I am sure a solution will appear.
Hilton.
 
Upvote 0

Hilton

Active Member
Licensed User
Longtime User
I am not using the clvexpandable class, however, I will try it and report back. Thank you.
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
I am using the clv with the expanding and collapsing items ...
I am not using the clvexpandable class ...

My possible solution above (post#2) was on the assumption you were using the CLV Expandable .. but hopefully switching over might solve your issue.
 
Upvote 0

Hilton

Active Member
Licensed User
Longtime User
I have implemented the clv expandable and implemented a version of your (MJ) suggestion with the mouseclick. I was doing something very similar to the expandable class, but removing the code and using the class made me realise that I could have made it work with MJ's suggestion, but it is nicer to have the class. It is now working fine and I am better off for the experience.

Thank you both for your help.
 
Upvote 0
Top