B4J Question MouseDragged does not fire over a ScrollPane

Brian Dean

Well-Known Member
Licensed User
Longtime User
As the title says, pressing the main mouse button and dragging the mouse pointer across a scrollpane does not fire the MouseDragged event. By comparison a standard pane fires its MouseDragged event as one would expect.

Here is a demo so that you can try it for yourself. Is there something that I have overlooked? I know that I can fix this by overlaying a panel on top of the scrollview, but do I need to do that?
 

Attachments

  • MouseDemo.zip
    2.3 KB · Views: 138
Solution
The ScrollPane InnerNode doesn't appear to have the listeners added, presumably because you are expected to load a layout into it which could then potentially stop the listeners receiving events anyway. You can then access the mouse events on the views in the loaded layout.

Try the attached, It just has a pane loaded into the scrollpane.

stevel05

Expert
Licensed User
Longtime User
The ScrollPane InnerNode doesn't appear to have the listeners added, presumably because you are expected to load a layout into it which could then potentially stop the listeners receiving events anyway. You can then access the mouse events on the views in the loaded layout.

Try the attached, It just has a pane loaded into the scrollpane.
 

Attachments

  • MouseDemo-sl.zip
    3.2 KB · Views: 159
Last edited:
Upvote 0
Solution

Brian Dean

Well-Known Member
Licensed User
Longtime User
Try the attached, It just has a pane loaded into the scrollpane.
The other thing about a ScrollPane is that it's content doesn't autoresize
Thanks for these, @stevel05. What I am doing here is extending an existing app by adding a drag/drop function. The scrollview is actually empty - I put a canvas inside it and use that to construct a spreadsheet-style layout, so there are no inner views. I can either overlay a panel to capture the mouse events (I have already prototyped that approach) or, as you suggest, put a pane in the scrollpane and then use that as the base for my drawing canvas.

I think that your suggestion is the neatest - an overlay panel has to be fiddled to avoid the scrollbars. I will see if I can do a retrofit without too much disruption. I was surprised, though, that the MouseDragged event is shown in the prompt list provided by the IDE if it is not going to normally respond.
 
Upvote 0
Top