Hammerspoon / hammerspoon

Staggeringly powerful macOS desktop automation with Lua
http://www.hammerspoon.org
MIT License
12.06k stars 583 forks source link

How should I scroll the canvas, is there an API to generate a scroll canvas? #3671

Open HoChihchou opened 2 months ago

HoChihchou commented 2 months ago

I need to make an interface that can scroll up and down

muescha commented 2 months ago

for help you need provide more details - maybe show also your existing code.

asmagill commented 2 months ago

Generally speaking, hs.canvas objects don't scroll. You can mimic something similar programmatically by changing the location of objects within the canvas, and objects with positions outside of the canvas's frame (i.e. positions with negative numbers or positions greater than the height/width of the canvas) will "disappear" in the sense that they won't be displayed, but there is no mechanism for doing it automatically -- you have to move them programatically.

If you want a truly scrolling window in the traditional application style, most likely you need to be using hs.webview, which displays web pages (either remote or locally/programmatically generated). Full HTML and Javascript is supported... for the most part if Safari can render it, hs.webview can as well.

But as @muescha says, more details or seeing some of your existing code would help in determining what the best solution might be.