Page 1 of 1

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

Posted: Thu Feb 13, 2014 2:12 am
by Mag
... to reach the button, right? 8)

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

Posted: Thu Feb 13, 2014 2:52 am
by Simon
Yep

Simon

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

Posted: Thu Feb 13, 2014 2:59 am
by Mag
Thank you Simon, and unfortunately, turn the field disabled to let mouse messages to pass, makes the text to become grayout... :cry:

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

Posted: Thu Feb 13, 2014 3:03 am
by Simon
Ok my turn to try my psychic abilities.

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

Simon

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

Posted: Thu Feb 13, 2014 3:23 am
by Mag
Thank you, exam passed. :D

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

Posted: Thu Feb 13, 2014 6:23 am
by dunbarx
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

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

Posted: Thu Feb 13, 2014 12:15 pm
by Mag
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.

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

Posted: Thu Feb 13, 2014 4:17 pm
by dunbarx
Mag.

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

Good ol' LC.

Craig

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

Posted: Thu Feb 13, 2014 4:23 pm
by FourthWorld
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?

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

Posted: Thu Feb 13, 2014 4:35 pm
by dunbarx
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

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

Posted: Thu Feb 13, 2014 4:47 pm
by Mag
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).

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

Posted: Thu Feb 13, 2014 5:04 pm
by FourthWorld
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.

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

Posted: Thu Feb 13, 2014 6:31 pm
by Mag
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.