How to check "if the target is a button" ?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
How to check "if the target is a button" ?
Is there a way to check the type of object that was clicked on?
I see that "is" and "is among" works only with number, words, etc.
Regards,
Sri
I see that "is" and "is among" works only with number, words, etc.
Regards,
Sri
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: How to check "if the target is a button" ?
For example:
Code: Select all
the target begins with "button "
shiftLock happens
Re: How to check "if the target is a button" ?
Of course, Hermann!
I'd used "the short name of the target" in my script, so "button" was not available to me! (forehead-slap)
Thanks!
Sri
I'd used "the short name of the target" in my script, so "button" was not available to me! (forehead-slap)
Thanks!
Sri
Re: How to check "if the target is a button" ?
And of course there are lots of variations, like
etc.
Code: Select all
word 1 of the target
last target
-
- VIP Livecode Opensource Backer
- Posts: 9580
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: How to check "if the target is a button" ?
Academic at this point, but just to close your original idea:
Craig
Code: Select all
answer word 1 of the long name of the target
-
- Livecode Opensource Backer
- Posts: 9287
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: How to check "if the target is a button" ?
-- Attachments
-
- object type.livecode.zip
- Here's the stack
- (974 Bytes) Downloaded 168 times
-
- VIP Livecode Opensource Backer
- Posts: 9802
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: How to check "if the target is a button" ?
Anyone know offhand whether both "the target" and "the name of the object" are affected by background buttons or card fields when the stack's hcAddressing property is set to true?
Sure, it's an edge case, and since that property was really only useful for HC ports it probably hasn't mattered in more than a decade. But for the sake of thoroughness it may be good to know.
Sure, it's an edge case, and since that property was really only useful for HC ports it probably hasn't mattered in more than a decade. But for the sake of thoroughness it may be good to know.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 9580
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: How to check "if the target is a button" ?
Never played with this before but a couple of things:
1- Cmd-D will not duplicate an object if the hcAdressing is "true"
2- Not a surprise, but one cannot group objects if "true". I did not know that hcAdressing limited a stack in the same way a HC stack would be. There must be many other similar restrictions...
3- As to the target and the name of, say, a backGround button, (that is, a button which is a child of a bg group) if hcAdressing is false:
if true:
Craig
1- Cmd-D will not duplicate an object if the hcAdressing is "true"
2- Not a surprise, but one cannot group objects if "true". I did not know that hcAdressing limited a stack in the same way a HC stack would be. There must be many other similar restrictions...
3- As to the target and the name of, say, a backGround button, (that is, a button which is a child of a bg group) if hcAdressing is false:
Code: Select all
button "Button"
button "Button"
Code: Select all
bkgnd button "Button"
bkgnd button "Button"
-
- VIP Livecode Opensource Backer
- Posts: 9802
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: How to check "if the target is a button" ?
Thanks, Craig.
So if we were to write a function taking hcAddressing into account, it might be something like this (off the cuff, test before using):
So if we were to write a function taking hcAddressing into account, it might be something like this (off the cuff, test before using):
Code: Select all
function ObjectType pObj
-- Check if valid object reference:
if there is not a pObj then return empty
-- Get stack name:
put the long id of pObj into tStack
put offset(" of stack ", pObj) into tOffset
delete char 1 to (tOffset+3) of tStack
-- Return value according to hcAddressing:
if the hcAddressing of stack tStack is true then
return word 2 of the name of pObj
else
return word 1 of the name of pObj
end if
end ObjectType
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn