send . . . at ?

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

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9375
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

send . . . at ?

Post by richmond62 » Sat May 27, 2023 10:11 am

The Richmond Fantasy Machine gets into top gear . . .

Is it possible to do this sort of thing in some sort of way?

Pseudocode [possibly]

send "mouseDown" at the mouseLoc

or

send "mouseDown" at 300,300

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9375
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: send . . . at ?

Post by richmond62 » Sat May 27, 2023 10:21 am

OR . . .

is it possible to do this sort of thing?

Pseudocode:

get the short name of the object at 300,300

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: send . . . at ?

Post by Klaus » Sat May 27, 2023 10:40 am

Hi Richmond,

real code:

Code: Select all

...
get controlAtLoc((300,300))
## returns -> control (number of control)
put the short name of it
...
Best

Klaus

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9375
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: send . . . at ?

Post by richmond62 » Sat May 27, 2023 11:04 am

Fantastic, Thank you Klaus. 8)

BUT:

a cardScript does not work:

Code: Select all

on mouseUp
   put the mouseLoc into ZZZZ
   get controlAtLoc((ZZZZ))
   put the short name of it into fld "XXX"
end mouseUp
Last edited by richmond62 on Sat May 27, 2023 11:10 am, edited 1 time in total.

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 261
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: send . . . at ?

Post by SWEdeAndy » Sat May 27, 2023 11:07 am

Alternative:

Code: Select all

send "mouseDown" to the mouseControl
Andreas Bergendal
Independent app and system developer
WhenInSpace: https://wheninspace.se

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: send . . . at ?

Post by Klaus » Sat May 27, 2023 11:21 am

richmond62 wrote:
Sat May 27, 2023 11:04 am
Fantastic, Thank you Klaus. 8)

BUT:

a cardScript does not work:

Code: Select all

on mouseUp
   put the mouseLoc into ZZZZ
   get controlAtLoc((ZZZZ))
   put the short name of it into fld "XXX"
end mouseUp
Just tested and works here!?
Of course you need to click on an existing control!

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9375
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: send . . . at ?

Post by richmond62 » Sat May 27, 2023 11:26 am

It DOES work if the pointer is over a button, but NOT if it is over a card: that throws an error:
-
SShot 2023-05-27 at 13.25.46.png
-
And that is predictable because a card is an object, not a control.

What I am looking for a something that will report what is UNDER the mouseLoc regardless of whether it is a control or an object.

AND . . .

objectAtLoc does not exist.

It also does not do much good over a field.

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 261
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: send . . . at ?

Post by SWEdeAndy » Sat May 27, 2023 11:39 am

richmond62 wrote:
Sat May 27, 2023 11:26 am
What I am looking for a something that will report what is UNDER the mouseLoc regardless of whether it is a control or an object.
Something like this (in the card script)?

Code: Select all

on mouseUp
   put the mouseControl into tObject
   if tObject is empty then put the name of the current card of the mouseStack into tObject
   put tObject
   pass mouseUp
end mouseUp

on openField
   put the mouseControl
   pass openField
end openField
Andreas Bergendal
Independent app and system developer
WhenInSpace: https://wheninspace.se

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9375
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: send . . . at ?

Post by richmond62 » Sat May 27, 2023 11:49 am

Exactly.

Love you!

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9375
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: send . . . at ?

Post by richmond62 » Sat May 27, 2023 4:01 pm

So: obviously I have gone wrong somewhere here as my list field is only filling up with something a bit meaningless:
-
SShot 2023-05-27 at 17.58.00.png
-
script of button "Detector":

Code: Select all

on mouseUp
   put empty into fld "PIX"
   put item 1 of the topLeft of this stack into stLR
   put item 2 of the topLeft of this stack into stUD
   put 280 into UD
   set the screenMouseLoc to (300 + stLR), (UD + stUD)
   repeat until UD > 320
      put the mouseControl into XYZ
      if XYZ is empty then
         put the name of the current card of the mouseStack after fld "PIX"
      else
         put XYZ after fld "PIX"
      end if
      put (":" && 300 & "," & UD && cr) after fld "PIX"
      add 1 to UD
      set the screenMouseLoc to (300 + stLR), (UD + stUD)
   end repeat
end mouseUp
Attachments
Grabbable Region 2.livecode.zip
Stack.
(1.41 KiB) Downloaded 55 times

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4000
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: send . . . at ?

Post by bn » Wed May 31, 2023 1:26 pm

richmond62 wrote:
Sat May 27, 2023 4:01 pm
So: obviously I have gone wrong somewhere here as my list field is only filling up with something a bit meaningless:
Richmond,

this works in your stack for button "Detector" for me. Don't ask me why.

Code: Select all

on mouseUp
   put empty into fld "PIX"
   put item 1 of the topLeft of this stack into stLR
   put item 2 of the topLeft of this stack into stUD
   put 280 into UD
   set the screenMouseLoc to stLR, stUD -- added
   set the screenMouseLoc to (300 + stLR), (UD + stUD)
   wait 30 milliseconds with messages -- added
   repeat until UD > 320
      put the mouseControl into XYZ
      if XYZ is empty then
         put the name of the current card of the mouseStack after fld "PIX"
      else
         put XYZ after fld "PIX"
      end if
      put (":" && 300 & "," & UD && cr) after fld "PIX"
      add 1 to UD
      set the screenMouseLoc to stLR, stUD -- added
      set the screenMouseLoc to (300 + stLR), (UD + stUD)
      wait 30 milliseconds with messages -- added
   end repeat
end mouseUp
I hardcoded a wait 30 milliseconds with messages. If it does not work for you try to increase the milliseconds.

But I still do not understand why you would want to use the screenMouseLoc and why you do not use the mouseLoc and test if it is within the rect of any of the controls of the card.

Kind regards
Bernd

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9375
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: send . . . at ?

Post by richmond62 » Wed May 31, 2023 1:48 pm

why you would want to use the screenMouseLoc
because mouseLoc was not working.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4000
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: send . . . at ?

Post by bn » Wed May 31, 2023 9:48 pm

Hi Richmond,

What I was asking is why you do not use something like this:

Code: Select all

on mouseUp
   put empty into field "PIX"
   put the name of this card into tCdName
   
   repeat with i = the number of controls of this card down to 1
      put the rect of control i into tArray[i]
   end repeat
   
   put the keys of tArray into tKeys
   sort tKeys descending numeric
   
   repeat with y = 280 to 320
      put false into tFoundOne
      put 300,y into tTestLoc
      
      repeat for each line aKey in tKeys
         if tTestLoc is within tArray[aKey] then
            put "control" && aKey && tTestLoc & cr after tCollect
            put true into tFoundOne
            exit repeat
         end if
      end repeat
      
      if tFoundOne is false then
         put tCdName && tTestLoc & cr after tCollect
      end if
      
   end repeat
   delete char -1 of tCollect -- a return
   put tCollect into field "PIX"
end mouseUp
The code I posted earlier did work this morning, but not this evening. It seems to need a special time of the day to work....

However the code I post here is supposed to work at any time of the day.

Kind regards
Bernd

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”