Hi, I have a button (can be a panel or an image), and clicking on the left part diagonally does one thing.
If the right part is pressed diagonally it does something else.
How can I control it?
Thank you very much.
Private Sub MyNicePanel_Touch (Action As Int, X As Float, Y As Float)
If Action = MyNicePanel.TOUCH_ACTION_UP Then
If x < MyNicePanel.Width/2 Then
Log("Clicked on the left side")
Else
Log("Clicked on the right side")
End If
End If
End Sub
Hi, thanks for your help, although I think it is no good, because if you click from the middle of the button downwards, on the right side, then it will think that you have clicked on the left side.
Notice that it is diagonal, as if it were two triangles.
I know, i gave you a very simple example. Now you know how you can do this. In your case you need to check the x and y value, to find out which diagonal page was clicked on
With some corrections (orientation, left position, etc.) it can be a simple condition (assumption square button)
B4X:
Private Sub MyNicePanel_Touch (Action As Int, X As Float, Y As Float)
If Action = MyNicePanel.TOUCH_ACTION_UP Then
If y > x Then
Log("Clicked on the left side")
Else
Log("Clicked on the right side")
End If
End If
End Sub
Thank you very much, it works perfectly.
And also in a very simple way, I was trying to make calculations by measuring the hypotenuse and... I was breaking my head.
If ((MyNicePanel.Width - X) / MyNicePanel.Width) > (Y / MyNicePanel.Height) Then
Log("Clicked on the left side")
Else
Log("Clicked on the right side")
End If
Edit : OOPS! Might have put the inequality the wrong way!
Thank you very much, it works perfectly.
And also in a very simple way, I was trying to make calculations by measuring the hypotenuse and... I was breaking my head.
If ((MyNicePanel.Width - X) / MyNicePanel.Width) > (Y / MyNicePanel.Height) Then
Log("Clicked on the left side")
Else
Log("Clicked on the right side")
End If
Edit : OOPS! Might have put the inequality the wrong way!