A text field over a button prevents mouse messages...

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
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

A text field over a button prevents mouse messages...

Post by Mag » Thu Feb 13, 2014 2:12 am

... to reach the button, right? 8)

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: A text field over a button prevents mouse messages...

Post by Simon » Thu Feb 13, 2014 2:52 am

Yep

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: A text field over a button prevents mouse messages...

Post by Mag » Thu Feb 13, 2014 2:59 am

Thank you Simon, and unfortunately, turn the field disabled to let mouse messages to pass, makes the text to become grayout... :cry:

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: A text field over a button prevents mouse messages...

Post by Simon » Thu Feb 13, 2014 3:03 am

Ok my turn to try my psychic abilities.

I'd group them and put the mouseUp into the grp script.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: A text field over a button prevents mouse messages...

Post by Mag » Thu Feb 13, 2014 3:23 am

Thank you, exam passed. :D

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: A text field over a button prevents mouse messages...

Post by dunbarx » Thu Feb 13, 2014 6:23 am

This harkens to a thread on this forum just a couple of weeks ago, The idea Simon had of grouping the two controls, and putting a mouseUp handler in the group so that the action would appear to come from the underlying button is clever. But it has issues in that only one button can be taken as the target within that group unless clickLoc stuff is managed as well.

I was involved with that thread, and so am writing to say why not just set the behavior of the field to the underlying button? Of course, this will only work in a locked field, unless other shenanigans, like using "mouseDown" are used. Always gratified that LC offers a way, if only I am patient. And sometimes lucky.

Craig Newman

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: A text field over a button prevents mouse messages...

Post by Mag » Thu Feb 13, 2014 12:15 pm

Thank you Craig, very interesting considerations.

I found also another way to add to our list of ways: set the text field disabled property true and its foregroundColor property to black.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: A text field over a button prevents mouse messages...

Post by dunbarx » Thu Feb 13, 2014 4:17 pm

Mag.

Just so. And though a kluge of sorts, is simpler than mine.

Good ol' LC.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: A text field over a button prevents mouse messages...

Post by FourthWorld » Thu Feb 13, 2014 4:23 pm

Why not just disable the button? Wouldn't it be confusing to the user to have a button that appears enabled but doesn't respond to clicks?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: A text field over a button prevents mouse messages...

Post by dunbarx » Thu Feb 13, 2014 4:35 pm

Richard.

The button is covered by a text field, which displays text.

The idea was similar to one I mentioned a little while back, that it might be useful to have a property of a control that made it "transparent" to mouseClicks. So if the overlying field had this property, the click would "pass" through to an underlying control.

The several solutions in this thread all are workarounds to this "missing" property.

Craig

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: A text field over a button prevents mouse messages...

Post by Mag » Thu Feb 13, 2014 4:47 pm

I post here an example of the button where the text field is used like a label for the button (and set to disabled and with a foregroundColor assigned to it).
Attachments
FieldOverAButton.livecode.zip
(6.71 KiB) Downloaded 168 times

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: A text field over a button prevents mouse messages...

Post by FourthWorld » Thu Feb 13, 2014 5:04 pm

Thanks, Mag. Very helpful to see what you're building.

It seem the desire to use an overlay field is a workaround for the vertical alignment issue when setting the button's icon to the background image. But if you set the icon back to 0 and set the button's backgroundPattern to the id of the image, I think you'll have what you're looking for in a single object. Note that you'll also need to set the opaque of the button to true; it's currently set to false.

Alternatively, if you truly needed a compound custom object you could group the button and field together and set the behavior on the resulting group, which would trap events regardless of which control within the group got the message.

But if your result looks as good as my quick tweak of the button here, I think you'll find that just setting the button's backgroundPattern will do what you're looking for.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: A text field over a button prevents mouse messages...

Post by Mag » Thu Feb 13, 2014 6:31 pm

Yes, you're right, that was the reason why I used the text field. I tried what you suggested (simple and straightforward) and it works fine. Thank you!

PS
I post here the new version.
Attachments
FieldOverAButton2.livecode.zip
(6.71 KiB) Downloaded 170 times

Post Reply