mouseUp pButtonNumber

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

mouseUp pButtonNumber

Post by trags3 » Sat Sep 28, 2019 9:37 pm

Hi this is driving me crazy,
I have a lot of fields on a card. I put a value in a different field called employee and when I click on any of the other empty fields on the card I want the name in the fld"employee" to be copied into the field I clicked on.
I am using LC 9.5.0 Build 15503 on a Macbook Air OS Mojave Version 10.14.6

The code in all of my fields of interest is:

on mouseUp
put fld"employee" into me
end mouseUp

on the Mac, I have a 3 button mouse.
This only works when I click using the right mouse button.
It doesn't matter to me if it works that way but I also want it to work with the left button.

I tried this code:

on mouseUp pButtonNumber
put pButtonNumber into tNum
if tNum = 1 then
answer tNum
end if
If tNum = 3 then
answer tNum
end if
end mouseUp

If I click on the field with the left mouse the answer is 1 if the right mouse the answer is 3.
I change the code to:

on mouseUp pButtonNumber
put pButtonNumber into tNum
if tNum = 1 then
put fld"employee" into me
end if
If tNum = 3 then
put fld"employee" into me
end if
end mouseUp

The name in the clicked on field only changes if I use the right mouse click.

Is this a bug or am I doing something terribly wrong?

Thanks Tom

Klaus
Posts: 14206
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: mouseUp pButtonNumber

Post by Klaus » Sat Sep 28, 2019 10:09 pm

Hi Tom,

not sure I fully understand your problem, but here some hints:

Code: Select all

on mouseUp pButtonNumber
  put pButtonNumber into tNum
  if tNum = 1 then
...
There is no need to use and fill another variable with the content of the variable
which acts as the parameter to the "mouseup" handler! :D

Code: Select all

## You can name the parameter whatever you want to, so this will do:
on mouseUp tNum
 if tNum <> 2 then
    answer tNum
 end if
 ## :-)
end mouseUp
HINT:
Only LOCKED ( locktext = true) fields will receive all "mouseXX" messages.
Unlocked = editable fields only the RIGHT click (tNum = 3!) message (so we can supply context menus etc.)
So if that is the case in your stack, you now know why. :-)

If that is not what you mean, please give more info.

Best

Klaus

trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

Re: mouseUp pButtonNumber

Post by trags3 » Sun Sep 29, 2019 12:15 pm

Thanks Klaus,
The offending fields were unlocked.
Tom

Post Reply