Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callback for clicking on highlight #76

Open
Krastanov opened this issue Nov 15, 2024 · 5 comments
Open

Callback for clicking on highlight #76

Krastanov opened this issue Nov 15, 2024 · 5 comments

Comments

@Krastanov
Copy link

Thank you for creating this, it is incredibly useful!

Is it currently possible to detect a user clicking on the pdf and doing a callback that provides where the click is and maybe saying on top of which highlight the click happened?

@Krastanov
Copy link
Author

I see this is a duplicate of the wontfix #4

I understand this will not be added. If you have a moment to spare, I would be grateful if you can share your thoughts on the difficulties behind implementing something like this.

@lfoppiano
Copy link
Owner

Hi @Krastanov, in brief, the way Streamlit works that at each interaction refresh the page makes things difficult. I did try some time ago but I don't remember what was the blocking problem.

Currently if you see the scrolling to page or to annotation it's not perfect, mostly for the way Streamlit works. If you have knowledge in javascript and want to contribute I will be happy to integrate a PR. 😄

@lfoppiano
Copy link
Owner

Thank you for creating this, it is incredibly useful!

Is it currently possible to detect a user clicking on the pdf and doing a callback that provides where the click is and maybe saying on top of which highlight the click happened?

Sorry I did not see this first message. I'm quite busy with other stuff at the moment. It's possible but as I wrote before there were problems, in particular I did try to pass a function but it was not working as I expected. The best is to trial and error, unfrotunately at the moment I don't have time really.

@t29mato any suggestion or insight on this?

@Socvest
Copy link

Socvest commented Dec 2, 2024

Hi @Krastanov, in brief, the way Streamlit works that at each interaction refresh the page makes things difficult. I did try some time ago but I don't remember what was the blocking problem.

Currently if you see the scrolling to page or to annotation it's not perfect, mostly for the way Streamlit works. If you have knowledge in javascript and want to contribute I will be happy to integrate a PR. 😄

This is true but with the release of fragments, reruns are not so much a problem.

@t29mato
Copy link
Collaborator

t29mato commented Dec 3, 2024

@lfoppiano
Thank you for your patience. I have implemented the feature, so please review it.
lfoppiano/structure-vision#4
#80 (to test)

@Socvest
The fragments feature seems to be a very useful decorator.
For now, I have implemented it using the Streamlit.setComponentValue method. Since it didn’t trigger a re-render, I believe the UX is fine for now. However, if you have any better ideas, please feel free to suggest them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants