Script viewport position
-
I believe this was already asked somewhere but I couldn't find it.
Is there a way to script the vertical or horizontal scrolling of a viewport?
-
@d-healey Nope you can't... I tried to implement it myself but the viewport is a very strange beast in Hise, and I don't see the relation to Juce and where/how to modify the existing behaviour (or add methods)
-
I've added a
viewPositionX
andviewPositionY
property to the viewport, so you can set it using the usual methods.However it's unidirectional though, so scrolling the viewport with the scrollbar will not change this property (adding this is a bit more complicated, but let me know if you require this).
-
@Christoph-Hart Thank you, I'll play around with it this afternoon.
-
I needed this to be unidirectional for now so all good. Because when you add child panels to a list, sometimes (although not always) the viewport was following the incrementing list which is rarely the behavior you want. So setting it back to 0 pos when reconstructing the list is cool. I was using a trick for this before having a method.
-
@Christoph-Hart Yep this works perfectly!
-
Can we get bidirectional support for this? I have a list with a lot of items (child panels) and I'm wondering if I can use the viewport position Y to dynamically add/remove content as the list is scrolled.
I tried with a broadcaster but it doesn't appear to work.
HiseSnippet 954.3ocsV0saaaCElxIpqQasncnO.B5J2gfTKO2DuETT233rYr5Ti4rrNLTTvRRYQDIRAJ5jZTz1a66Ueg1av1g5GaoDizTCLegg442uC424b7XkjvRSkJjkyIySXHquydxbgNreHlKPCODYcW6Q3TMS4lK5f4I3zTFEYYswuXDXs0lnrO+ySO.GgED1RQHzoRNg8bdLWuT53d+FOJ5HLkcBOth0c5MjHE8kQxY.d1vtEJASNCOkcL1XVCazuhSCQV+fM0uiePWBd2t9cZSHs6tW6eZOBCGDv10+w60oaPm.LoUaj0sFP4ZoZhFqYoPPOPRmOITdgHOAmxS4uIhYN3il.YNWLpeHOhNt7xIEgr1b7xqpMxupdf8HNkuP9xqr6kovcoGUuzrZbcPx+q.RVUfzl4P591SHJdhdoFCd9V6gB3EDtRX0fRtsnF62vtuDrPn2IFeF6HEbXgGM2sUqscgud39NNO5QtGnjXJImRPYAbAWykBG3kKU6dNV4lRTxnn+DqIgfIOwcfXJWv1gnXPAWw6luyiS89YWuZN3ssqGVMMET72dDYbhT.3xHMQISXJ8byuOGGMi48p2WfIrViIgtZoK6bvZWykgSsvtStImH6WFxw4giyRa5cJmcQhTo8yhMbXrLMqr9Ki.u5YIfqfJMhC0ffotbZnzmWnoIbs4MhowPLBlIHl30bQEssaY8rsaV07Pm24rE7LjJiX6jn3Bcyb466.kYY.bkhikZ1KDMyr248NtWVUPvJ0YdgMHE.1pTaZEUWmiMEyheCSUEsFCApWc97stY7YRNgqhgRwPfK8hDVw4ijQTCO076qx9QELVSePABAS0YcAeeQW.iV9vh3TSavh2YTVQTcPE5OFdHViKCWMBBH6P14vfr7lrsrOjkdlVljYaw6IT323j+1kIdXu4UObAmpCWHn2G6Ex3SC0UkTKmeSdNuSYaOVvhxR2cqJIKi1Vl.Lu7GWJSe3xY5SetWBVAIoR1pVCnqN7AF6Ioyhv55yBMaIJT.DpZCfLCYDPm17paQ9JFP15ZGPdSg38sGygt2UiwFq.i.I4+CLVrV4N1Cf8XD8R.to8Qubc2g7ER+uKmo4hoivZE2PRNdV7DX8KgAYW.TmTCeogocK+bqR9yDlflc3egOEJ8MmsJT5WpDEigQjulj2jZVbc6LI.lDYK12B9GFvY2UzUFC6QeMgTOTWww1qqi+355Xm00wGutNt6553dqqic+xNZ9aNOalVFm21fPiFOHaJpk0.AFXfYrUz+gw.sdf
// Broadcaster definition const var scrollWatcher = Engine.createBroadcaster({"id": "scrollWatcher", "args": ["component", "property", "value"]}); // attach to event Type scrollWatcher.attachToComponentProperties("Viewport1", "viewPositionY", ""); // attach first listener scrollWatcher.addListener(0, "Meta", function(component, property, value) { Console.print(value); // Gives weird results. });
-
@d-healey That's strange, it should work, but maybe you need to use mouse callback instead?
I had an old version to monitor the viewPositions, using the panels hover event to get the positions
Maybe you could have some use of itHiseSnippet 1105.3ocsV81aaTCF2WaOfbvlXH9.Xcu5JppKoj0VXZhrllBQrzEQJElpplb84jypWrO4yoknoBukuW7EhuAvisujbWV5XJhkWT0m++64283G69JIkkmKUHufyllwPdel+foBcR6DBWf5dLx6g98H4ZlB6TczzLRdNKF44s42aT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LtwJvHLr7g.iEOM3A9cf2kP0K.3V9m7qeXdG.5mjSzvpvdDshCCK9mNY7.34TTFTcALBYNL6sg4XmSttQ1v.CXhXqv+.+JL1vH6UXrwLinwD3ZtWScGVMO93SrZ.LIrOTqF7hQPFuhSmig2B8ZJsZpdq.2acC7qW2.attA9j0Mv8W2.OXcC7v+6.MOU84SzxwtiMHTu9craS875HHvDncZE8uZ1egZC
-
@d-healey I made it messy, you only need this:
const getViewposY = Engine.createBroadcaster({ "id": "getViewposY", "args": ["component", "event"], "tags": [] }); getViewposY.attachToComponentMouseEvents([Content.getComponent("Viewport1")], "All Callbacks", ""); getViewposY.addListener([viewPositionY], "something", function(component, event) { if (event.hover) { Console.print(component.get("viewPositionY")); } });
-
@ulrik Oh that's a cool solution, thanks!