enable mouse messages when button down
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
enable mouse messages when button down
I designed some UI interaction on the whiteboard. Now that I'm trying to code them I found that Livecode is doing the exact opposite of what I'd like. Messages like mouseEnter are suppressed when the mouse button is down.
What I'd like to do is let the user click on one node, drag the mouse to another node, release the mouse, and get a link between them. But I want to show them a preview of what they're about to get so that if that's not what they want they can move the mouse back and release it on the original node, which won't change anything (like in chess where if you don't take your hand off the piece the move isn't committed). So I need to track what controls the mouse is crossing over so that I can update the preview in real time.
Is there a way to enable mouse messages even when the button is down? And also a way to have them sent to the controls the mouse is over instead of the control where the button was originally held down?
Part of the reason I favored this input pattern is that it should work perfectly fine for touch interfaces too. But I'm not familiar with using touch messages. Do they have the same suppression where the finger won't send messages to the things it passes over when it's dragged across the screen?
What I'd like to do is let the user click on one node, drag the mouse to another node, release the mouse, and get a link between them. But I want to show them a preview of what they're about to get so that if that's not what they want they can move the mouse back and release it on the original node, which won't change anything (like in chess where if you don't take your hand off the piece the move isn't committed). So I need to track what controls the mouse is crossing over so that I can update the preview in real time.
Is there a way to enable mouse messages even when the button is down? And also a way to have them sent to the controls the mouse is over instead of the control where the button was originally held down?
Part of the reason I favored this input pattern is that it should work perfectly fine for touch interfaces too. But I'm not familiar with using touch messages. Do they have the same suppression where the finger won't send messages to the things it passes over when it's dragged across the screen?
Re: enable mouse messages when button down
Hi.
The "mouseEnter" message is sent when the mouse is released inside a control, even though it was ignored when the mouse actually entered that control and the mouse was down. Try this. With two buttons, place this in the "starting" button:
And in the "target" button:
Craig Newman
The "mouseEnter" message is sent when the mouse is released inside a control, even though it was ignored when the mouse actually entered that control and the mouse was down. Try this. With two buttons, place this in the "starting" button:
Code: Select all
on mouseDown
put the name of me
end mouseDown
Code: Select all
on mouseEnter
put " :" & random(999) after msg
end mouseEnter
Re: enable mouse messages when button down
Thanks, that's interesting. Seems like it's more confusing than useful at that point. It's not queuing the messages because it doesn't send mouseEnter, mouseLeave, mouseEnter if all of those happened while the mouse was down.
But it also doesn't help. I was hoping to use the built in mouse messages while the mouse was down. Apparently that's exactly the opposite of what Livecode expects.
So is there a way to reverse that setting? To tell Livecode to keep sending mouse messages even though the button is down?
But it also doesn't help. I was hoping to use the built in mouse messages while the mouse was down. Apparently that's exactly the opposite of what Livecode expects.
So is there a way to reverse that setting? To tell Livecode to keep sending mouse messages even though the button is down?
Re: enable mouse messages when button down
Not AFAIK but look at mouseStillDown and mouseMove. I would probably look first at setting a "nodeLink" flag on mouseDownand rresetting it on mouseUp or mouseRelease.
Then on mouseMove check for the nodeLink state, if true then check if the mouse is within the rect of a target node and if so, highlight what you need.
Then on mouseMove check for the nodeLink state, if true then check if the mouse is within the rect of a target node and if so, highlight what you need.
Re: enable mouse messages when button down
Hi Matt,
maybe you could "mis-use" the DRAGxxx messages in this case!
These ARE sent when the mouse is "down"!
Best
Klaus
maybe you could "mis-use" the DRAGxxx messages in this case!

These ARE sent when the mouse is "down"!
Best
Klaus
Re: enable mouse messages when button down
SparkOut - Thanks, but I'd like to make use of Livecode's existing engine. I COULD rewrite the logic that continuously tracks whether or not the mouse has entered a particular area...but there are already supposed to be messages for that.
Klaus - I see what you mean about 'abusing' the drag messages. They seem to be intended to transfer data. Is there maybe a catch to it? I've been able to trigger the dragStart message but none of the other drag messages.
Klaus - I see what you mean about 'abusing' the drag messages. They seem to be intended to transfer data. Is there maybe a catch to it? I've been able to trigger the dragStart message but none of the other drag messages.
Re: enable mouse messages when button down
It looks like I can make due using mouseMove and within.
I can catch mouseMove relatively easily check if the mouseLoc is within the rect of every node in a repeat. That's not nearly as clean as just getting a message from the control the mouse crosses into, but it looks like Livecode just straight up doesn't send those messages when the button is down. I'll ask about that at the next user group meeting.
I can catch mouseMove relatively easily check if the mouseLoc is within the rect of every node in a repeat. That's not nearly as clean as just getting a message from the control the mouse crosses into, but it looks like Livecode just straight up doesn't send those messages when the button is down. I'll ask about that at the next user group meeting.
Re: enable mouse messages when button down
Hi Matt,
and then check that string "on dragdrop" on the target and then do your "connection of lines".
best
Klaus
I could think about setting "the dragdata" to a string (maybe the long ID of the target?) "on dragstart"mattmaier wrote:Klaus - I see what you mean about 'abusing' the drag messages. They seem to be intended to transfer data. Is there maybe a catch to it? I've been able to trigger the dragStart message but none of the other drag messages.
and then check that string "on dragdrop" on the target and then do your "connection of lines".
best
Klaus
Re: enable mouse messages when button down
Well here's a quick and dirty way of getting the principle achieved. It doesn't take into account actually fixing what you want done with the selected nodes, but you should be able to see how mouseMove can be used to track a mouse while the button is held down and test when it is within the rect of any target object.
It uses a behavior (stored in a hidden button) for each of the "nodes". Click on any one, drag with the mouse button held down and let go over another node to link the two with a simple graphic line.
It uses a behavior (stored in a hidden button) for each of the "nodes". Click on any one, drag with the mouse button held down and let go over another node to link the two with a simple graphic line.
- Attachments
-
- Link_Nodes_Test.zip
- (1.99 KiB) Downloaded 352 times
-
- Livecode Opensource Backer
- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Re: enable mouse messages when button down
I've just made a "quick-n-dirty" stack:
and the card contains this script:
on mouseMove
put empty into fld "fff"
if the mouseLoc is within the rect of grc "g1" then
put "in the yellow blob" into fld "fff"
end if
if the mouseLoc is within the rect of grc "g2" then
put "in the pink blob" into fld "fff"
end if
end mouseMove
and that works regardless of whether the mouse is Down or Up.
and the card contains this script:
on mouseMove
put empty into fld "fff"
if the mouseLoc is within the rect of grc "g1" then
put "in the yellow blob" into fld "fff"
end if
if the mouseLoc is within the rect of grc "g2" then
put "in the pink blob" into fld "fff"
end if
end mouseMove
and that works regardless of whether the mouse is Down or Up.
- Attachments
-
- mg.zip
- Here's the stack.
- (788 Bytes) Downloaded 343 times
Re: enable mouse messages when button down
I appreciate the examples. I've also implemented something using mouseMove.
The question this thread is based on is still whether or not it's possible to re-enable the mouse messages even though the mouse button is down. Livecode is based on messages. There are commands that manipulate those messages, like stopping them, or forcing a message. So maybe there's a way to enable mouse messages when the button is down. That would be a lot more consistent with how Livecode works in every other case.
I can't even find an explanation of why it would make sense to disable the normal mouse messages when the button is down. Clearly someone thought it made sense because most of the messages are disabled. But in my case it's the exact opposite of making sense, so I want to just reverse it.
The question this thread is based on is still whether or not it's possible to re-enable the mouse messages even though the mouse button is down. Livecode is based on messages. There are commands that manipulate those messages, like stopping them, or forcing a message. So maybe there's a way to enable mouse messages when the button is down. That would be a lot more consistent with how Livecode works in every other case.
I can't even find an explanation of why it would make sense to disable the normal mouse messages when the button is down. Clearly someone thought it made sense because most of the messages are disabled. But in my case it's the exact opposite of making sense, so I want to just reverse it.
-
- Livecode Opensource Backer
- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Re: enable mouse messages when button down
Because of mouseStillDown . . .
Re: enable mouse messages when button down
Thanks for posting Link_Nodes_Test! Great script notes and –for me– helpful intro to Custom Properties.
rebuilding visual programming app originally created in 1993 as Hypercard stack