Jump to content




Detect Mouse Hover on an Advanced Computer?

lua help computer

  • You cannot reply to this topic
2 replies to this topic

#1 Endergreen117

  • Members
  • 33 posts

Posted 14 October 2014 - 08: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.

#2 wieselkatze

  • Members
  • 221 posts
  • LocationGermany

Posted 14 October 2014 - 08: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 by wieselkatze, 14 October 2014 - 08:30 PM.


#3 Dog

  • Members
  • 1,179 posts
  • LocationEarth orbit

Posted 14 October 2014 - 08: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 by Dog, 14 October 2014 - 08:31 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users