B4J Question No MouseEvent on an ImageView

Midimaster

Active Member
Licensed User
I have a ListView with 20 items (rows) on it. The rows are defined as Panes. On each Pane are some buttons and a ImageView on the right side:

1601300098738.png


Now I need a possibility to receive the x-position of the mouse inside the ImageView.

As long as I do not press the Mousebutton I receive in ImageEvent_MouseMoved values from 0 (left) to 100 (right).
B4X:
Private Sub VolumeEvent_MouseMoved (EventData As MouseEvent)
    Log( EventData.PrimaryButtonDown)
    Dim locImage As ImageView=Sender
    Log("volume " & locImage.Tag & " " &  EventData.x  )
End Sub

But if I keep the button pressed and move over the image I do not longer receive the ImageEvent_MouseMoved (EventData As MouseEvent) but the pane or item gets selected. (blue)

Does anybody knows a solution?
 

klaus

Expert
Licensed User
Longtime User
Instead of VolumeEvent_MouseMoved use VolumeEvent_MouseDragged.
MouseMoved is raised when you hover above the node. This doesn't exist in B4A
MouseDragged is raised when you press a button and hover over the node. B4A equivalent TOUCH_MOVE in the Touch event.
MousePressed is raised when you press a button. B4A equivalent TOUCH_DOWN in the Touch event.
MouseReleased is raised when you release a button. B4A equivalent TOUCH_UP in the Touch event.
 
Upvote 0

Midimaster

Active Member
Licensed User
Thank you Klaus. This works better. At the moment I transcripe my B4A-app to B4J and its the first time for me to use B4J. so I struggle often with finding the best event for something.

new problem:
now I observe, that only starting at the blue parts of the image will start the events. If I start in the transparent part on the left side over the volume 1 the events are not thrown.
I think this is because my image is transparent there. Will filling the whole image rectangle with a nearly transparent white solve this behavior?

And how can I stop, that the parent item gets selected (blue)?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I don't think that the transparency has any influence on the events.

I would suggest you to use the XUI library with B4XViews etc.
If you use a Pane for the image instead of an ImageView you could use the Touch event of the Panel / Pane B4XView.
With this, the code would be the same for both platforms!
 
Last edited:
Upvote 0
Top