Page 1 of 1

mouseLoc

Posted: Sun Oct 13, 2024 3:08 pm
by richmond62
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:

Code: Select all

set the mouseLoc to 500, 500
will not work . . .

Re: mouseLoc

Posted: Sun Oct 13, 2024 3:25 pm
by Klaus
richmond62 wrote:
Sun Oct 13, 2024 3:08 pm

Code: Select all

set the mouseLoc to 500, 500
will not work . . .
Well, "the mouseloc" is READ-ONLY!
richmond62 wrote:
Sun Oct 13, 2024 3:08 pm

Code: Select all

set the screenMouseLoc to 500, 500
Do something like this:

Code: Select all

set the screenMouseLoc to (the left of this stack + 500),(the top of this stack + 500)
8)

Re: mouseLoc

Posted: Sun Oct 13, 2024 4:06 pm
by dunbarx
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

Re: mouseLoc

Posted: Sun Oct 13, 2024 4:49 pm
by Randy Hengst
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

Re: mouseLoc

Posted: Mon Oct 14, 2024 4:37 am
by dunbarx
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

Re: mouseLoc

Posted: Mon Oct 14, 2024 5:26 am
by Randy Hengst
I think you’re right, Craig. I should have said, I put that code in a button.

Re: mouseLoc

Posted: Mon Oct 14, 2024 8:37 am
by Klaus
I think Richmond got the picture now. 8)

Re: mouseLoc

Posted: Mon Oct 14, 2024 9:40 am
by richmond62
I have, Thank you. 8)

Needlessly complicated.

Re: mouseLoc

Posted: Mon Oct 14, 2024 12:22 pm
by andresdt
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:

Code: Select all

set the mouseLoc to 500, 500
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

Re: mouseLoc

Posted: Mon Oct 14, 2024 5:09 pm
by jacque
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.

Re: mouseLoc

Posted: Mon Oct 14, 2024 7:42 pm
by stam
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...

Re: mouseLoc

Posted: Mon Oct 14, 2024 8:39 pm
by andresdt
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)

Re: mouseLoc

Posted: Mon Oct 14, 2024 10:05 pm
by dunbarx
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

Re: mouseLoc

Posted: Mon Oct 14, 2024 10:20 pm
by jiml
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