Get the screen position of the cursor

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

Re: Get the screen position of the cursor

Post by richmond62 » Sun Nov 28, 2021 5:31 pm

SShot 2021-11-28 at 18.29.39.png
Attachments
Type & Respond.livecode.zip
Here's the stack
(16.48 KiB) Downloaded 91 times

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9580
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Get the screen position of the cursor

Post by dunbarx » Sun Nov 28, 2021 6:52 pm

Richmond.

You do not need all that. You can examine the "textChanged" message as you type each char, and see if the last three of the field fall into any of the stock patterns that will engender a substitution.

That is not what I am asking. It is whether it is required that the typist be alert to the current context so that he enters any of the prescribed text patterns.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9580
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Get the screen position of the cursor

Post by dunbarx » Sun Nov 28, 2021 7:01 pm

Richmond.

I did not mean to be short. Sorry.

Anyway, in the field script, simply place:

Code: Select all

on textChanged
   if char - 3 to - 1 of me = "//t" then beep
end textChanged
The "beep" here just means we have typed a certain pattern, and now is the time to show the menu.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9580
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Get the screen position of the cursor

Post by dunbarx » Sun Nov 28, 2021 7:09 pm

@banjaxd

If you see my last post, we might enhance the one-liner to read something like:

Code: Select all

if char - 3 to - 1 of me is among the lines of the patterns of this card then....
The "patterns of this card" is a custom property that contains, perhaps:
"//t"
"//p"
etc.
Now the menu can see that (1) it is time to reveal itself, and (2) will know which pattern was typed, and (3) will be able to populate itself with the appropriate menuItems

So much fun

Craig
Last edited by dunbarx on Mon Nov 29, 2021 2:40 am, edited 4 times in total.

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

Re: Get the screen position of the cursor

Post by richmond62 » Sun Nov 28, 2021 7:12 pm

I did not mean to be short.
It'll take more than that to offend me. 8)

Anyway, as a teacher, I tend to like to be long-winded: especially as all my code is worked out as I go along.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9580
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Get the screen position of the cursor

Post by dunbarx » Sun Nov 28, 2021 9:22 pm

I never work out my code as I go along.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9580
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Get the screen position of the cursor

Post by dunbarx » Mon Nov 29, 2021 3:32 am

@banjaxd

Try this demo stack and me know if it works for you as a starter. You can change the actual menuItems, which are located in the custom properties of the card, as needed.
WordSelector.livecode.zip
(1.51 KiB) Downloaded 91 times
Craig

banjaxd
Posts: 5
Joined: Sat Nov 27, 2021 1:34 pm

Re: Get the screen position of the cursor

Post by banjaxd » Mon Nov 29, 2021 12:46 pm

@Craig - thank you for the example, that's an ideal solution.

Also thank you to everyone else for your contribution and support. I'll post a link to the full solution when I'm done :)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9580
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Get the screen position of the cursor

Post by dunbarx » Mon Nov 29, 2021 3:47 pm

banjaxd.

Good.

Make sure you check out the custom properties of the card to see how I put it together. That is where you will add your own tags and their contents.

Know also that the pulldown menu is made very small so that only the menuItems are visible. You can see that in the button script at the bottom of the card.

Craig

Post Reply

Return to “Talking LiveCode”