text over button prevents button from working |SOLVED|

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
Johan_VH
Posts: 67
Joined: Fri Mar 28, 2014 2:46 pm

text over button prevents button from working |SOLVED|

Post by Johan_VH » Fri Jul 04, 2014 4:01 pm

Hi all,

I made a button out of custom icons, basically a simple white square, and as down-state a grey square. On top of that button I have place 2 labels. One big one that covers 2 thirds of the button, one small one underneath that. I then grouped these 3 objects. When I test it however, the button only responds to my mouse when the mouse is over a part of the button that has no text on top of it.

So my problem is, the whole group should act as the button. I cannot seem to find how to prevent LiveCode from giving focus to the labels. I could of course just make different images in photoshop, but later on I will have to make an onscreen keyboard too, which should change the available characters according to the selected language, so I would really like to be able to create my buttons like this...

Any help is, as always, greatly appreciated!

Johan
Last edited by Johan_VH on Fri Jul 04, 2014 4:32 pm, edited 1 time in total.

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: text over button prevents button from working

Post by bangkok » Fri Jul 04, 2014 4:18 pm

-edit your group
-"send back" your label (via properties size&position)
-set your button/icon to not opaque

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

Re: text over button prevents button from working

Post by Klaus » Fri Jul 04, 2014 4:20 pm

Hallo Johan,
Johan_VH wrote:...When I test it however, the button only responds to my mouse when the mouse is over a part of the button that has no text on top of it.
yep, that is intended behavior.
Johan_VH wrote:I made a button out of custom icons, basically a simple white square, and as down-state a grey square.
Is this a BUTTON object you are using for this and you set its HILITE-ICON?
Johan_VH wrote:So my problem is, the whole group should act as the button.
The trick for "custom controls" (which are groups in fact) is to script the GROUP to do what you want.
So instead of setting the HILITE icon of the one button you do all thsi stuff by script, something like this in the group script:

Code: Select all

on mousedown
  set the icon of btn "your button name here" of me to 1006
  ## Replace 1006 with the ID of the image YOU are using!
  ## Same for MOUSEUP below
end mousedown

on mouseup
  set the icon of btn "your button name here" of me to 1005
  ## See above :-)
  ## Do your stuff here...
end mouseup

on mouserelease
  set the icon of btn "your button name here" of me to 1005
end mouserelease
You get the picture :D


Best

Klaus

Johan_VH
Posts: 67
Joined: Fri Mar 28, 2014 2:46 pm

Re: text over button prevents button from working

Post by Johan_VH » Fri Jul 04, 2014 4:32 pm

Hi,

I just wanted to come here to say I figured it out myself by changing the icon from a script, but you beat me to it. :D

thanks!

Johan

Post Reply