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

MouseUp/MouseDown events - implementation idea

Started by Lupus590, 20 August 2014 - 11:30 PM
Lupus590 #1
Posted 21 August 2014 - 01:30 AM
the main problem with mouse up in SMP is when two players are using the same computer (which is one of the main reasons that we don't have this feature)

why not use a vector for where each player moved their mouse while clicked down? so the drag would be passed to the cc computer as a single event, with start x,y and end x,y screen positions.

this may not seam ideal because we won't be able to add tool tips to the mouse while dragging, but we will be able to detect mouse release!

edit: (putting all my additions in one place)
the reason i posted this was to give another idea of how to get round the multi-user/mouse problem. by making the mouse down and up events as a single event per user, you negate the issue of not knowing which mouse went up (if using to separate events)

i even have an idea for maintaining comparability with existing scripts. the current event returns which mouse button was clicked and the x coord and y coord.

local event, button, xPos, yPos = os.pullEvent("mouse_click")
my idea is to add to that with the relative distance of the release point and the time that passed after the down "sub-event" to when the up "sub-event" happened

local event, button, xPos, yPos, xDist, yDist, duration = os.pullEvent("mouse_click")
Edited on 23 August 2014 - 11:29 AM
KingofGamesYami #2
Posted 21 August 2014 - 04:26 AM
I believe this was brought up and shot down here: http://www.computercraft.info/forums2/index.php?/topic/18620-event-key-gives-off-multiple-parameters-based-on-how-many-keys-are-pressed-at-the-same-time/page__st__20
Bomb Bloke #3
Posted 21 August 2014 - 04:36 AM
I still maintain that for basic up/down events, there's no need to worry about multiple users at all.
Lupus590 #4
Posted 23 August 2014 - 01:29 PM
the reason i posted this was to give another idea of how to get round the multi-user/mouse problem. by making the mouse down and up events as a single event per user, you negate the issue of not knowing which mouse went up (if using to separate events)

i even have an idea for maintaining comparability with existing scripts. the current event returns which mouse button was clicked and the x coord and y coord.

local event, button, xPos, yPos = os.pullEvent("mouse_click")
my idea is to add to that with the relative distance of the release point and the time that passed after the down "sub-event" to when the up "sub-event" happened

local event, button, xPos, yPos, xDist, yDist, duration = os.pullEvent("mouse_click")
Bomb Bloke #5
Posted 23 August 2014 - 02:22 PM
The problem with that is that a given mouse up event might not relate to any mouse down event. It's possible to click outside of the display, drag the mouse over it, then release.

You might say that "ComputerCraft then only needs to fire up events it has matching down events for", but to that I say there's no point in any such tracking to begin with - we've already got a mouse_drag event with which we are already fully capable of tracking a cursor's travels anyway.

It'd be (very) nice to know the position on the screen where up events occur, but other than that? They only valuable info you need out of them is that they happened. The rest you can work out for yourself within your scripts.
Sebra #6
Posted 23 August 2014 - 10:34 PM
It'd be (very) nice to know the position on the screen where up events occur, but other than that? They only valuable info you need out of them is that they happened. The rest you can work out for yourself within your scripts.
It is not true if you think about multitouch screen. Several players, several drags.
Previous pointer coords would be sufficient to distinguish each movement but not each player.
My opinion is "this would not happen".
Wojbie #7
Posted 24 August 2014 - 07:20 PM
It is not true if you think about multitouch screen. Several players, several drags.
Previous pointer coords would be sufficient to distinguish each movement but not each player.
My opinion is "this would not happen".

Truthfully? How often do 2 people use same computer? Usually one is doing and other is watching.
Sebra #8
Posted 24 August 2014 - 07:46 PM
the main problem with mouse up in SMP is when two players are using the same computer (which is one of the main reasons that we don't have this feature)…
It is not true if you think about multitouch screen. Several players, several drags.
Previous pointer coords would be sufficient to distinguish each movement but not each player.
My opinion is "this would not happen".

Truthfully? How often do 2 people use same computer? Usually one is doing and other is watching.
Just the case, OP author want to discuss. He want to draw something in pair with a friend probably.
Edited on 24 August 2014 - 05:47 PM