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
[feature request] Add tooltip (API) #91
Comments
Tooltips are very useful but I'm not sure how to make this possible in Window.js. The main reason is that Window.js is just an immediate-mode drawing canvas, whereas HTML browsers are retained-mode: https://en.wikipedia.org/wiki/Retained_mode This means that browsers know about elements and their position, but Window.js doesn't. So when the mouse hover at (100, 100), the browser knows whether that overlaps with an element that has a tooltip and can thus display it; but Window.js only "retains" the canvas content, which is just pixels really. So it wouldn't know what tooltips to show at what positions. That said, you still have a couple of options. You can implement tooltips yourself, by keeping a list of rectangles and the tooltip to show for each, and then checking whether the mouse is inside one of those rectangles whenever it moves. Basically, implement tooltips yourself :-) This is essentially what the browser does for you behind the scenes. This is also how videogames do "tooltips" or other animations on hover. |
@joaodasilva thanks for your answer! I'm not a C++ programmer so I can't help you... but talking about the tooltip API, because of the canvas only "browser", I would probably implement mouse cursor tracking and "auto-follow" by the tooltip and no element tooltip (I think it's impossible to do so), so like to "detect" hover on a button drawn and updating color (checking for mouse coordinates), it just needs a variable to update (issue opening example API with I don't know if what I'm saying can be made and is possible, but I think tooltips are a great way to "evolve" this project! Thanks another time!!! |
Would be great if I can use tooltips like in the browser, with a window.js API, obviously.
For example, I hover an element made on the canvas and, checking hover with mouse API, I can decide to show a tooltip if user stop the mouse in this position.
The API could be simply implemented so:
Please, if you like my idea, add a 👍 below!
The text was updated successfully, but these errors were encountered: