This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Endergreen117's profile picture

Detect Mouse Hover on an Advanced Computer?

Started by Endergreen117, 14 October 2014 - 07:23 PM
Endergreen117 #1
Posted 14 October 2014 - 09:23 PM
Hello, guys (and gals) !

Recently I have started working on a project that would require me to detect if the caret is hovering over a certain position of the screen. I was hoping someone here would be able to tell me how to do this, and I would prefer that after it detects that the caret is hovering it waits for a second or two. Ex: hovers mouse over button for 1 sec., moves away, nothing happens; hovers mouse over button for 2 sec., context menu appears!

Thanks, Cory Ackley.
wieselkatze #2
Posted 14 October 2014 - 09:28 PM
There is no such 'mouse_hover' event.
The best thing you could do is scrolling or clicking with the mouse when above the button - this will return the coordinates of where the mouse has scrolled/clicked.

Hovering is also not an option when it comes to CC event queues - it would just spam it and also there's the problem with multiple clients in one GUI.

EDIT:

If you mean the blinking cursor - that would be possible with term.getCursorPos()
You could do that by starting an os.startTimer( your-seconds-to-wait-until-context ) and os.pullEvent().

If that timer triggers and the cursor is still in the area of the button just trigger the context menu
Edited on 14 October 2014 - 07:30 PM
Dog #3
Posted 14 October 2014 - 09:30 PM
There is no mouse_hover event or the like for ComputerCraft. As I understand it, tracking and reporting the cursor position would involve sending a LOT of packets back and forth every time the cursor moves at all so it's just not feasible.

EDIT: :ph34r:/> 'd
Edited on 14 October 2014 - 07:31 PM