Click on View and long_click on the panel container

henry1311

Member
Licensed User
Longtime User
Hello!
I have a panel with 2/3/4 View.
If I click on each View i run the event 'click', and that's OK!
If I long_click on any view I should run the event (panel_click or panel_longClick) connected to the panel.

How can I fix?

Hello and thanks
Enrico
 

derez

Expert
Licensed User
Longtime User
Make subs for the views: sub [view]_longclick, and in every such sub call panel_longclick.
 
Upvote 0

henry1311

Member
Licensed User
Longtime User
Thanks for the reply.
The solution is ok, but I would need the reference (object) to the panel to be able to move the panel
In the vid there are several panel and each contains different view.
Can I know the object name of the container (panel) of a view? It could be the solution!
hello and thanks
Enrico
 
Upvote 0

henry1311

Member
Licensed User
Longtime User
at the time I solved this way:

B4X:
dim t as int = -1
For v = 0 To Activity.NumberOfViews-1
  If Activity.GetView(v) Is Panel Then
    Dim pnl1 As Panel = Activity.GetView(v)
    Log(v&" Tag="&pnl1.tag)
    For p = 0 To pnl1.NumberOfViews-1
      If pnl1.GetView(p) Is Button Then
        Dim tmpBtn As Button = pnl1.GetView(p)            
        If tmpbtn=Sender Then
          ' ok : panel that contains the view on which I made the long_click
          t=pnl1.tag
          exit
        End If
      End If         
    Next
  End If
  if t > -1 then
    exit
  end if
Next
...
...

Thank you very much David
Enrico
 
Last edited:
Upvote 0

Geezer

Active Member
Licensed User
Longtime User
Let me just verify what you were trying to do.

You have a panel with some views on, and want the normal click to trigger the view_click sub, but you want the long click to trigger the panel_longclick sub.

Is that correct ?
 
Upvote 0

henry1311

Member
Licensed User
Longtime User
it's correct.

one panel, some views inside.
event click in each view and event long_click on the panel.
In sub panel_longClick I have to know the object reference to the panel.
Ex :
pnl1 with in btn1, btn2, imgview1, ...
pnl2 with inside btn3, imgview2, ...
...
B4X:
pnl1.initialize ("Btn")
pnl2.initialize ("Btn")
btn1.initialize ("Btn")
btn2.initialize ("Btn")
btn3.initialize ("Btn")
imageview1.initialize ("imgv")
imageview1.initialize ("imgv")
sub btn_click
  dim btn as button
  btn = sender
  ...
end sub
sub imgv_click
  dim imgv as imageview
  imgvn = sender
  ...
end sub

sub pnl_longClick
  dim pnl as panel
  pnl = sender
  dim s1 as string = pnl.tag
  ...
  ... i must work with 'pnl' ... to move the panel and its views!
  ...
end sub

Hello and Thank You
Enrico
 
Upvote 0

Geezer

Active Member
Licensed User
Longtime User
If you are not defining tags on the individual views you could set the tag to the panel, and check the tag value.

Example

B4X:
Sub buttons_LongClick
   Dim but As Button = Sender
   Select Case but.Tag 
      Case "panel1"
         Panel1_LongClick
      Case "panel2"
         Panel1_LongClick
      Case Else
         Log ( "Another button was long clicked")
   End Select
End Sub
 
Upvote 0
Top