Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
richmond62
- Livecode Opensource Backer

- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Post
by richmond62 » Sun Oct 13, 2024 3:08 pm
I want to move my pointer away from a button after someone has clicked on it (so that someone with twitchy fingers doesn't keep clicking on it), and am well aware that I can do something like this:
Code: Select all
set the screenMouseLoc to 500, 500
BUT this is not ideal as I should like the pointer to remain inwith the bounds of my stack, and:
will not work . . .
-
Klaus
- Posts: 14177
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Sun Oct 13, 2024 3:25 pm
richmond62 wrote: ↑Sun Oct 13, 2024 3:08 pm
will not work . . .
Well, "the mouseloc" is READ-ONLY!
Do something like this:
Code: Select all
set the screenMouseLoc to (the left of this stack + 500),(the top of this stack + 500)

-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10305
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Sun Oct 13, 2024 4:06 pm
I have always wished that the mouseLoc was more than read-only. Why the screenMouseLoc works both ways and not the mouseLoc has always bothered me.
Anyway, you have to involve "stack coordinates" to find a suitable loc within a card. Klaus alluded to this in his handler. I would move the cursor to a loc nicely just off the control of interest, instead of to an arbitrary value, which in a small card may not even be visible, or in the middle of another control, or something worse.
Craig
-
Randy Hengst
- VIP Livecode Opensource Backer

- Posts: 157
- Joined: Thu Jun 29, 2006 4:16 pm
Post
by Randy Hengst » Sun Oct 13, 2024 4:49 pm
How about:
on mouseUp
local tTopLeftOfStack
local tTopRightOfTarget
local tNewMouseLoc
put the topLeft of this stack into tTopLeftOfStack
put the topright of target into tTopRightOfTarget
--create new screenMouseLoc
put item 1 tTopLeftOfStack + item 1 tTopRightOfTarget & "," into tNewMouseLoc
put item 2 tTopLeftOfStack + item 2 tTopRightOfTarget after tNewMouseLoc
set the screenMouseLoc to tNewMouseLoc
end mouseUp
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10305
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Mon Oct 14, 2024 4:37 am
Randy.
I think Richmond wanted to have a gadget that took a loc near but not too near a specific control; he mentioned a button.
Craig
-
Randy Hengst
- VIP Livecode Opensource Backer

- Posts: 157
- Joined: Thu Jun 29, 2006 4:16 pm
Post
by Randy Hengst » Mon Oct 14, 2024 5:26 am
I think you’re right, Craig. I should have said, I put that code in a button.
-
Klaus
- Posts: 14177
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Mon Oct 14, 2024 8:37 am
I think Richmond got the picture now.

-
richmond62
- Livecode Opensource Backer

- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Post
by richmond62 » Mon Oct 14, 2024 9:40 am
I have, Thank you.
Needlessly complicated.
-
andresdt
- Posts: 156
- Joined: Fri Aug 16, 2019 7:51 pm
-
Contact:
Post
by andresdt » Mon Oct 14, 2024 12:22 pm
richmond62 wrote: ↑Sun Oct 13, 2024 3:08 pm
I want to move my pointer away from a button after someone has clicked on it (so that someone with twitchy fingers doesn't keep clicking on it), and am well aware that I can do something like this:
Code: Select all
set the screenMouseLoc to 500, 500
BUT this is not ideal as I should like the pointer to remain inwith the bounds of my stack, and:
will not work . . .
Hi, just a suggestion. Instead of changing the cursor position, why don't you disable the button so that it can't be clicked again.
Code: Select all
on mouseUp
disabled me
-- your code
enable me
end mouseUp
-
jacque
- VIP Livecode Opensource Backer

- Posts: 7389
- Joined: Sat Apr 08, 2006 8:31 pm
-
Contact:
Post
by jacque » Mon Oct 14, 2024 5:09 pm
I prefer the disabled suggestion. Moving the mouse is disorienting for the user and not recommended. I'd disable the button on mouseUp and re-enable it after a short delay. And sometimes just blocking mouseDoubleUp is enough.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
-
stam
- Posts: 3061
- Joined: Sun Jun 04, 2006 9:39 pm
Post
by stam » Mon Oct 14, 2024 7:42 pm
Agreed - it should be like online transactions for example. Once you click submit, the button is disabled to prevent you from being changed multiple times. It would be weird if the mouse moved off the button... and it still wouldn't stop me from clicking twice...
-
andresdt
- Posts: 156
- Joined: Fri Aug 16, 2019 7:51 pm
-
Contact:
Post
by andresdt » Mon Oct 14, 2024 8:39 pm
Regarding changing the mouse position within the stack rectangle. You can do it like this
Code: Select all
local tRandomPosition
put random(the width of this stack), \ -- X
random(the height of this stack) \ -- Y
into tRandomPosition
set the screenMouseLoc to globalLoc(tRandomPosition)
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10305
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Mon Oct 14, 2024 10:05 pm
Andre.
Sure, but if you follow the thread here I think you will agree that standard user interface practice recommends the disable method. I always get hung up on solving the posted issue with LC tools, rather than thinking more broadly. I leave that sort of thing to Jacque, oh, and you.
Craig
-
jiml
- Posts: 339
- Joined: Sat Dec 09, 2006 1:27 am
Post
by jiml » Mon Oct 14, 2024 10:20 pm
Or if the users are really 'twitchy'
Code: Select all
on mouseUp
beep
disable me
send "enab" to me in 100 ticks
end mouseUp
on enab
enable me
get flushevents("mouseUp")
end enab